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

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.