반응형
Notice
Recent Posts
Recent Comments
관리 메뉴

꿈꾸는 사람.

[Windows][MySQL 8.0.13][JDBC Driver] time zone 오류 해결 본문

IT/Database

[Windows][MySQL 8.0.13][JDBC Driver] time zone 오류 해결

현무랑 니니 2018. 12. 18. 17:39
반응형

MySQL 설정 후 Spring에서 테스트 시 아래와 같이 [time zone] 오류가 발생한다.

(JAVA1.8, MySQL 8, Spring Tool Suite Version: 3.7.3.RELEASE)


1. [time zone] 오류

java.sql.SQLException: The server time zone value '´ëÇѹα¹ Ç¥ÁؽÃ' 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.

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

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

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

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

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

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)

at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)

at java.sql.DriverManager.getConnection(DriverManager.java:664)

at java.sql.DriverManager.getConnection(DriverManager.java:247)

at com.nini.niniapp1.MySQLConnectionTest.testConnection(MySQLConnectionTest.java:34)


2. MySQL에서 time zone 설정 확인

2.1 command line에서 확인


mysql> SELECT @@global.time_zone, @@session.time_zone;

+--------------------+---------------------+

| @@global.time_zone | @@session.time_zone |

+--------------------+---------------------+

| SYSTEM             | SYSTEM              |

+--------------------+---------------------+

1 row in set (0.00 sec) 



2.2 workbench에서 확인


3. SpringToolSuite 3.7.3에서 JDBC Driver 변경

MySQL JDBC 드라이버를 UTC 시간대로 사용하려면 serverTimezone를 연결 문자열에 명시적으로 지정해야 한다.

DriverManager.getConnection()의 URL에 아래 정보를 추가해야 한다.

jdbc:mysql://localhost:3306/nini_schema?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC


4. 수정 후 아래와 같이 정상 동작한다.

반응형
Comments