Spring SPRINGMVC MyBatis
Key points when configuring multiple data sources:
1. Note the configuration of the transaction interceptor
Transaction management in spring is bound to the data source, and once the program executes to the service layer (transaction management), because the transaction has been connected to the data source through the interceptor before entering the layer, it is not possible to switch the data source at that level.
Therefore, the tangent point (DataSource) should be configured on the upper level of the transaction, which is the controller layer.
Because the controller, service, DAO layer three is used
In the DAO layer, sqlsession is called to connect to the database and cannot be changed, because it is called sqlsession first, then through the function's pointcut.
At the service level, transactions are used. If you are at the service layer, you can only change the data source for the operation after the first operation.
So switch the data source, only in the controller layer, to do the pointcut. This allows the modified data source to be used when the transaction is invoked.
2. Oracle authorized read-only user
Create a new read-only user Myread
Give the read-only user the following roles: Connect, resource
Add read-only user-to-table SELECT permission, and authorize.
To add the name of the table owner before the table, use the following format when the user calls the data in the table
SELECT * from OWNER. USERS
Spring Dynamic Multi-data source