我想知道是否有人可以幫助我我試圖連接到在線數據庫。數據庫放在http://labs.cms.gre.ac.uk/db/mysqlnew.php上,但我似乎無法連接,繼承人到目前爲止,任何人都可以幫忙嗎?Java連接到在線數據庫
另外我需要導入任何東西嗎?我有import.hava.sql。*;但那是它?
try {
System.out.println("Attempting Database Connection");
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://http://labs.cms.gre.ac.uk/database";
connection = DriverManager.getConnection(url, "user", "pass");
stmt = connection.createStatement();
System.out.println("Connection made");
} catch (Exception e) {
System.out.println("Database connection attempt failed");
System.out.println(e);
}
}
您收到了什麼錯誤? – user902383
你看過這裏嗎? http://labs.cms.gre.ac.uk/db/mysqljconnect.asp – user902383