티스토리 뷰
[네이버 부스트코스 웹 프로그래밍] JDBC 실습 MySQL The server time zone value 에러
SUNO(수노) 2020. 2. 29. 19:52https://www.edwith.org/boostcourse-web/lecture/20653/
[LECTURE] 2) JDBC 실습 : edwith
들어가기 전에 이번 시간엔 JDBC를 이용해 데이터베이스에서 입력/수정/조회/삭제를 하는 프로그램을 만들어 보도록 하겠습니다. 학습 목표 JDBC를 이용해 입력/수정/삭제/... - 부스트코스
www.edwith.org
MySQL 8.0.19 사용중
영상에서 하란 대로 따라하고 JDBCExam1.java를 실행했을 때 에러가 발생한다.
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:836)
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.sunovivid.dao.RoleDao.getRole(RoleDao.java:23)
at com.sunovivid.JDBCExam1.main(JDBCExam1.java:9)
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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:2118)
at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2142)
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)
... 7 more
null
서버 타임 존에 대한 에러가 뜬다. 해당 에러를 검색해 보니 해결책이 여러 개 뜬다.
나는 https://offbyone.tistory.com/318 글을 보고 해결했다.
MySQL(MariaDB) 서버 타임존 설정하기
Java에서 MySQL 서버에 연결하니 다음과 같은 에러가 발생하였습니다. ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql..
offbyone.tistory.com
Connection 객체를 얻어올 때 dburl 뒤에 ?serverTimezone=UTC 혹은 ?serverTimezone=Asia/Seoul으로 설정해 준다. 현재 KST로 설정되어 있어서 에러가 발생한다고 한다.
jdbc:mysql://localhost:3306/newdb
from
private static String dburl = "jdbc:mysql://localhost:3306/newdb";
to
private static String dburl = "jdbc:mysql://localhost:3306/newdb?serverTimezone=Asia/Seoul";
잘 된다.