hanker

Spring - MySQL 연동 테스트 본문

SPRING

Spring - MySQL 연동 테스트

hanker 2021. 1. 8. 14:50
반응형
public class DBConnectionTest {
	private static final String DRIVER = "com.mysql.cj.jdbc.Driver"; // MySQL 8.x
    									// MySQL 5.x = com.mysql.jdbc.Driver
	private static final String URL = "jdbc:mysql://localhost:3306/스키마명?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true";
	private static final String USER = "아이디입력";
	private static final String PASSWORD = "비밀번호입력";
	
	@Test
	public void testConnection() throws Exception{
		Class.forName(DRIVER);
		
		try(Connection con = DriverManager.getConnection(URL, USER, PASSWORD)){
			System.out.println(con);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}

 

반응형