In spring + struts + mybatis, the error org. hibernate. exception. GenericJDBCException: Connection is read-only. Queries leading to data modification are not allowed causes and solutions, modification
Spring. xml: File
1 <tx: advice id = "txAdvice" transaction-manager = "transactionManager"> 2 <tx: attributes> 3 <tx: method name = "save *" propagation = "REQUIRED" read-only = "false"/> 4 <tx: method name = "add *" propagation = "REQUIRED" read-only = "false"/> 5 <tx: method name = "delete *" propagation = "REQUIRED" read-only = "false"/> 6 <tx: method name = "update *" propagation = "REQUIRED" read-only = "false"/> 7 <tx: method name = "list *" propagation = "REQUIRED" read-only = "true"/> 8 <tx: method name = "get *" propagation = "REQUIRED"/> 9 <tx: method name = "import *" propagation = "REQUIRED" read-only = "false"/> 10 <tx: method name = "export *" propagation = "REQUIRED" read-only = "true"/> 11 <tx: method name = "*" propagation = "REQUIRED" read-only = "true"/> 12 </tx: attributes> 13 </tx: advice>
Analysis: The methods involved in transactions in the service layer are not named according to the above rules. The preceding configuration file specifies that the database operation function must start with the above string, otherwise, the database access permission is read-only according to the default configuration.
Cause of error: Because the method name in the service layer violates the above rules, you only need to change the method name.
Solution: 1. Modify the method name in the service to conform to the rules of the configuration file.
2. Of course, you can also remove read-only = "true" (this method is not recommended)