IT Business

The server time zone value 'KST' is unrecognized or represents more than one time zone.

ilovejua 2023. 4. 10. 09:49
반응형

원인

 - WAS DB 연결하고자 하는 Timezone 'KST' 인식할 없어서 발생

 

조치

 - JDBC URL serverTimezone 추가

 

조치 예시

 - jdbc:mysql://127.0.0.1:3306/mydb_name?serverTimezone=Asia/Seoul

 

serverTimezone Asia/Seoul 하는 이유는 Error에서 'KST'  timezone으로 연결하려고 했는데 실패했기 때문에 넣었지만 정확하게 설정하고 싶으면 아래 내용을 참고

 

  • Mysql timezone 확인하기
    • SELECT @@time_zone, now();
    • Time_zone SYSYTEM 경우 system_time_zone 확인
    • SHOW VARIABLES WHERE Variable_name LIKE '%time_zone%';
  • system_time_zone이  KST일때 JDBC URL옵션에 ServerTimezone UTC 연결할 경우, 쿼리 SELECT문의 시간 정보 리턴
    • Select now()  결과 (한국시간 2023-04-03 09:55:46에 조회)
JDBC 조회 DB에서 직접 조회
2023-04-03 18:55:46 2023-04-03 09:55:46

 

에러 내용

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (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 specific time zone value if you want to utilize time zone support.)

        at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)

        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

 

 

Caused by: java.sql.SQLException: 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 specific time zone value if you want to utilize time zone support.

        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)

 

Caused by: 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 specific time zone value if you want to utilize time zone support.

        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)