package CHAP16;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class C15_01_ConnectionTest {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/world?useSSL=false&serverTimezone=UTC";
        String user = "root";
        String password = "123456789";

        try {
            // JDBC 드라이버 로드
            Class.forName("com.mysql.cj.jdbc.Driver");

            // 데이터베이스 연결
            Connection conn = DriverManager.getConnection(url, user, password);
            
            // 연결 성공 메시지 출력
            if (conn != null) {
                System.out.println("MySQL 데이터베이스 연결 성공!");
                conn.close();  // 연결 종료
            }
        } catch (ClassNotFoundException e) {
            System.out.println("JDBC 드라이버 로드 실패: " + e.getMessage());
        } catch (SQLException e) {
            System.out.println("데이터베이스 연결 실패: " + e.getMessage());
        }
    }
}