1

In my project, I want method A,B use database1, and all other methods use database2. Now I write like this in controller

DataSourceHolder.putDataSource("db1");
String code = methodA();//for get some
DataSourceHolder.putDataSource("db2");
methodC(code);
...
DataSourceHolder.putDataSource("db1");
methodB(code);//for set some
DataSourceHolder.putDataSource("db2");

In most cases, it runs normally. But while many people visit my webset, it may use wrong dataSource. Some data can not be saved or updated.

doubleevil
  • 41
  • 2

0 Answers0