티스토리 뷰
728x90
Mysql 8이하버전은 com.mysql.jdbc.Driver을 사용하였지만 Mysql 8이상은 com.mysql.cj.jdbc.Driver 으로 사용한다.
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically
registered via the SPI and manual loading of the driver class is generally unnecessary.
Mysql로 접속시에 이런 오류가 발생할수있다.
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)
Mysql 8이상은 아래와 같이 URL을 수정해서 넣어줘야한다.
?serverTimezone=UTC
package com.security.demo;
import static org.junit.Assert.*;
import java.sql.Connection;
import java.sql.DriverManager;
import org.junit.Test;
public class MysqlTest1 {
private static final String DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String URL = "jdbc:mysql://127.0.0.1:3306/test1?serverTimezone=UTC";
private static final String USER = "root";
private static final String PW = "비밀번호";
@Test
public void test() throws Exception {
Class.forName(DRIVER);
try (Connection con = DriverManager.getConnection(URL, USER, PW)){
System.out.println("성공");
System.out.println(con);
} catch (Exception e) {
System.out.println("에러발생");
e.printStackTrace();
}
}
}
추가적으로 ?characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false 로 사용하여도 좋다.
'DB server > Mysql&MariaDB' 카테고리의 다른 글
[MySQL] DELETE, UPDATE 에러코드 1175 (0) | 2019.07.17 |
---|