public Connection generateConnection() throws DataException {

String strDbName="imhrs";
String strUserName="root";
String strPassWord="root";

String strSQL="jdbc:mysql://localhost/"+strDbName;

Connection connection=null;
try{
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("mysqljdbcConection.............................error.....");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
System.out.println("mysqljdbcConection.............................error.....");
e.printStackTrace();
}
connection=DriverManager.getConnection(strSQL,strUserName,strPassWord);

} catch (ClassNotFoundException e) {
// TODO �Զ���� catch ��
e.printStackTrace();
} catch (SQLException e) {
// TODO �Զ���� catch ��
e.printStackTrace();
}

return connection;
}

这是链接代码
下面的是报的错:
Access denied for user 'imhrs'@'localhost' (using password: YES)
 这个错误的含义是什么了,还有就是 using password:YES这句话的意思是什么了。

解决方案 »

  1.   

    就是说你没有连接权限,到MySQL中检查一下你的用户名和登录机器的限制,mysql告诉的信息就是:imhrs这个用户没有权利从localhost上登录,即使你的密码是正确的
      

  2.   

    String strSQL="jdbc:mysql://localhost:3306/"+strDbName端口号得要吧
      

  3.   

    查看mysql用户的权限问题吧,用户在localhost不能登录,端口号也是需要的,