친절한 개발자

mysql connector 6.0.2 사용시 Could not get JDBC Connection 에러 발생 본문

개발일지

mysql connector 6.0.2 사용시 Could not get JDBC Connection 에러 발생

착한 개발자 2016. 6. 20. 13:43

오라클로 개발을 하다가 오래간만에 mysql을 접하게 되었다..


jdbc connection 셋팅이야 그리 어려운 것이 아니기때문에


mybatis 와 연동하려고 셋팅하고 db 접속 테스트를 실시하는 순간..


Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

Mon Jun 20 13:36:25 KST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

6월 20, 2016 1:36:25 오후 org.apache.catalina.core.StandardWrapperValve invoke

심각: Servlet.service() for servlet [appServlet] in context with path [/mudangrace] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)


에러가 발생하였다.... 


분명 셋팅에 문제가 없는데. 왜 그렇까? 혹시나 하고 jdbc connection 버전을 예전 버전으로 돌렸더니.. 이런 에러가 사라졌다.


그러면 분명 jdbc connection 버전이 올라가면서 뭔가 영향을 주었으리라...


mysql 공식 문서를 참고하였더니.... 음.. 역시 


보통 연결 URL은 jdbc:mysql://{ip}:{port}/{databasename} 이렇게 사용하였는데..


serverTimezone 이라는 것이 추가 되었던 것이다..


따라서 jdbc:mysql://{ip}:{port}/{databasename}?serverTimezone=UTC로 설정하니 정상적으로 동작한다.


그리고 DriverClass는 com.mysql.jdbc.Driver --> com.mysql.cj.jdbc.Driver 변경되었다..




참고로 아래는 dataSource를 이용하여 connection Pool을 설정할때 발생되는 에러 유형이다.


https://bobswift.atlassian.net/wiki/display/SQL/Data+source+configuration+-+problem+determination