2008年5月8日 星期四

Java連MySQL

要連線到MySQL必須先有MySQL JDBC的Driver。可以到此下載

String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/accounting";
String user = "howard";
String password = "howardgogogo";

try {
Class.forName(driver);
Connection connection = Driver.Manager.getConnection(url, user, password);
}
catch (ClassNotFoundException ...
...

0 意見: