IT

SQL 에러

Malto93 2022. 1. 24. 14:55

 

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 specifc time zone value if you want to utilize time zone support.
        at sun.reflect.GeneratedConstructorAccessor15.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
        at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
        at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
        at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2120)
        at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2143)
        at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)
        at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:967)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
        ... 34 more

mysql-connector 를 5.x.x.x --> 8.x.x.x로 변경한 뒤 발생
8 버전부터는 어떤타임존을 사용할 지 명시적으로 지정해주어야 한다고 함

 

1. JDBC URL 에 serverTimeZone 속성을 추가

AS IS jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
TO BE jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Seoul

2. 혹은 드라이버를 이전 버전으로 교체 
>> mysql-connector-java-5.1.39-bin.jar