Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/testsinix?user=admin&password=123456","","");
改成:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/testsinix?user=admin&password=123456");

解决方案 »

  1.   

    密码错误啊,如果你肯定用户名admin用密码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");
      

  2.   

    try
       {
           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");
       }