1. 程式人生 > >eclipse連結資料庫

eclipse連結資料庫

public class JDBCDemo {//資料庫連結
    private static final String DATABASE_DRIVER = "com.mysql.jdbc.Driver";
    private static final String URL = "jdbc:mysql://localhost:3306/mysql?useSSL=false";
    private static final String DATABASE_USER = "root";
    private static final String DATABASE_PASSWORD = "ngkj123";
    public static void main(String[] args) throws Exception {
        Connection conn = null;
        Class.forName(DATABASE_DRIVER);
        conn = DriverManager.getConnection(URL, DATABASE_USER, DATABASE_PASSWORD);
        System.out.println(conn);
        conn.close();
    }
}