首先系统必须具有com.jdbc.mysql.Driver,也就是mysql的驱动。从 或者
如:
public static void main(String argv[])
{
String url="jdbc:mysql://218.192.175.84:3306/dcampusfw?user=root&password=test";
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(url);
PreparedStatement pm=conn.prepareStatement("select * from test");
ResultSet rs=pm.executeQuery();
pm.close();
conn.close();
rs.close();
System.out.println("OK!");
}
catch (Exception ex) {
System.out.println (ex.getLocalizedMessage());
}
}
阅读(1007) | 评论(0) | 转发(0) |