Cause:java.sql.SQLException:Could not retrieve transation read-only status server

Source: Internet
Author: User
Tags mysql version


Background


Recently in the deployment of a complete set of projects, the deployment process encountered a lot of problems, in order to summarize some such as the title of this error!


    • Environment Description:
      using a distributed database , using the mysql!
### Cause: java.sql.SQLException: Could not retrieve transation read-only status server
; SQL []; Could not retrieve transation read-only status server; nested exception is java.sql.SQLException: Could not retrieve transation read-only status server, dubbo version: 2.5.3, current host: 127.0.0.1
org.springframework.dao.TransientDataAccessResourceException: 
### Error querying database.  Cause: java.sql.SQLException: Could not retrieve transation read-only status server
Troubleshoot problems


Because the code of the project has not changed, the current set of code has been run on the production, the cause of the error is not encountered in the previous production.


1, error, online search related information


By finding information on the Internet,
There are two ways to say it:
1), modify the isolation level of the database, andREPEATABLE-READmodify it toREAD-COMMITED.
2), database and application database driver (MySQL driver version inconsistent)


2. View database Information
mysql> SHOW VARIABLES LIKE ‘%iso%‘;
+-----------------------+-----------------+
| Variable_name         | Value           |
+-----------------------+-----------------+
| transaction_isolation | REPEATABLE-READ |
| tx_isolation          | REPEATABLE-READ |
+-----------------------+-----------------+
mysql> select version();
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    662239
Current database: shop

+-----------------------------------+
| VERSION()                         |
+-----------------------------------+
| 5.7.21-dbproxy-4.0-20180412155855 |
+-----------------------------------+


The discovery database configuration is indeedREPEATABLE-READ, because I cannot arbitrarily change this database, the database isolation level this business has the close relationship, then first solves from the version whether matches, has asked the related colleague:



q : Hello, 5.7.21-dbproxy-4.0-20180412155855 This version of the MySQL driver is required, the minimum MySQL driver is supported how much?
answer : 5.1.27~5.1.35



Check out the MySQL driver configuration for the current project, and discover that it is 5.1.24, version below the required version.


3. Upgrade MySQL Driver


Upgrade the MySQL version to 5.1.30, redeploy, find or error, and then upgrade to 5.1.32, after deployment, found no error. The problem is solved!


Summarize


There may be a number of ways to solve a problem, choose the most appropriate method, such as the above problem, there are two possible solutions, one is to modify the MySQL isolation level, a modification of the application of the MySQL driver version, the impact on the business is smaller, that must be Modify the MySQL driver version .



If you think this blog is helpful to you, please praise or like, let more people see, thank you!



If handsome (beautiful), Wise (Smart), and I as simple and good you see this blog post there are problems, please point out, I humbly accept you let me grow criticism, thank you for reading!
I wish you a happy day!



Welcome to visit my csdn blog, we grow together!



No matter what you do, just stick to it and see it differently! On the way, decently!



Blog home: http://blog.csdn.net/u010648555



? A punk who's getting better every day.



Cause:java.sql.SQLException:Could not retrieve transation read-only status server


Related Article

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.