Connection is read-only. Queries leading to data modification are not allowed
2018-02-06 09:55
2416 查看
看了下mysql-connector-5.1.40版本中,如果设置failoverReadOnly=true (即默认值,参考链接),当mysql连接failover时,会根据jdbc连接串将当前连接的readOnly值设置为true (第8行代码)
当执行update操作时,如果检测到readonly,就会跑出createSQLException (第8-9行代码)
上述报错信息是PreparedStatement.34和PreparedStatement.35,查mysql connector的LocalizedErrorMessages.properties
报错信息一致。
因此, 如果是使用的主备mysql,需要手动切换master和slave,如果使用的是多主的mysql(例如,phxsql),需要设置failoverReadOnly=false
因此, 如果是使用的主备mysql,需要手动切换master和slave,如果使用的是多主的mysql(例如,phxsql),需要设置failoverReadOnly=false
相关文章推荐
- Connection is read-only. Queries leading to data modification are not allowed
- (dao)Connection is read-only. Queries leading to data modification are not allowed
- Connection is read-only. Queries leading to data modification are not allowed
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
- jeeplus Connection is read-only. Queries leading to data modification are not allowed
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
- Connection is read-only. Queries leading to data modification are not allowed
- Connection is read-only. Queries leading to data modification are not allowed
- 执行update操作的话,就会报“Connection is read-only. Queries leading to data modification are not allowed”的异常。
- Connection is read-only. Queries leading to data modification are not allowed
- springboot JPA Connection is read-only. Queries leading to data modification are not allowed
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
- Connection is read-only. Queries leading to data modification are not allowed
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
- Connection is read-only. Queries leading to data modification are not allowed
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
- Connection is read-only. Queries leading to data modification are not allowed
- Connection is read-only. Queries leading to data modification are not allowed