반응형


자바 프로젝트 내부에서 jdbc드라이버를 연결하는 도중 다음과 같은 에러가 발생하였다.


detailMessage = "Could not create connection to database server. Attempted reconnect 3 times. Giving up."

cause = com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'KST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.



[ 소스코드 ] 

DriverManger.getConnection하는 과정에서 발생

final private static String url = "jdbc:mysql://10.111.eee.xxx:5555/db?characterEncoding=utf8";
final private static String usr = "vuser";
final private static String pwd = "pwd11111";

Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url, usr, pwd);
Statement stmt = conn.createStatement();


[ 문제해결 ] 

mysql-connector-java 버전 5.1.X 이후 버전부터 KST타임존을 인식하지 못하는 이슈가 있다고 한다.

따라서 url에 serverTimezone을 추가해준다!

"&serverTimezone=UTC"

String url = "jdbc:mysql://10.111.eee.xxx:5555/adflat?characterEncoding=utf8&serverTimezone=UTC";


이렇게 하면 손쉽게 해결할 수 있다~아니면 mysql-connector-java버전을 낮추거나~

반응형

+ Recent posts