eclipse連結資料庫
阿新 • • 發佈:2019-01-01
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();
}
}