mysql connector 에러 - Could not retrieve transation read-only status server, Unknown system variable 'tx_read_only'

🐶🦶·2022년 11월 25일
0

정리

목록 보기
9/9

에러메시지

2022-11-25 09:23:12 [Thread-12] ERROR jdbc.sqltiming - 8. Connection.isReadOnly()
java.sql.SQLException: Could not retrieve transation read-only status server
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:904) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:894) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3613) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3582) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isReadOnly(DelegatingConnection.java:459) ~[tomcat-dbcp.jar:8.5.75]
	at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isReadOnly(DelegatingConnection.java:459) ~[tomcat-dbcp.jar:8.5.75]
	at net.sf.log4jdbc.ConnectionSpy.isReadOnly(ConnectionSpy.java:645) ~[log4jdbc-remix-0.2.6.jar:na]
	at org.springframework.jdbc.datasource.DataSourceUtils.resetConnectionAfterTransaction(DataSourceUtils.java:220) [spring-jdbc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:360) [spring-jdbc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:1017) [spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:811) [spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) [spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504) [spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292) [spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) [spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at com.naon.biz.gw.attend.service.AtnBatchService$$EnhancerBySpringCGLIB$$1.execCalendarBatchData(<generated>) [classes/:na]
	at com.naon.biz.gw.init.InitWas.lambda$0(InitWas.java:169) [classes/:na]
	at java.lang.Thread.run(Thread.java:750) ~[na:1.8.0_322]
Caused by: java.sql.SQLException: Unknown system variable 'tx_read_only'
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2531) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2489) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1446) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3607) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	... 17 common frames omitted

mysql 5.7버전까지는 driverClassName을 com.mysql.jdbc.Driver 를 그대로 사용하지만 8버전 부터는 com.mysql.cj.jdbc.Driver 를 사용한다.

  • 해결방법
  1. pom.xml에 mysql-connector 8.0.17 버전을 추가해줌.
    maven build... 에서 clean installmaven update도 진행해준다.
<dependency>
		   <groupId>mysql</groupId>
		   <artifactId>mysql-connector-java</artifactId>
		   <version>8.0.17</version>
</dependency>
  1. driverClassName 변경해줌
    com.mysql.jdbc.Drivercom.mysql.cj.jdbc.Driver
profile
Live positive!

0개의 댓글