Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/testsinix?user=admin&password=123456","","");
改成:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/testsinix?user=admin&password=123456");
改成:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/testsinix?user=admin&password=123456");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/testsinix?user=admin&password=123456","","");
改成:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/testsinix?user=admin&password=123456","admin","123456");
{
String userName = "testuser";
String password = "testpass";
String url = "jdbc:mysql://localhost/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
}