请教jdbc连接mysql的问题。
try {
String url="jdbc:mysql://localhost:3306/sysMng";
String user="root";
String passwd="";
try {
Class.forName("org.gjt.mm.mysql.Driver");
System.out.println("Opening db connection");
System.out.println(conn);
conn = DriverManager.getConnection(url, user, passwd);
}
catch (ClassNotFoundException ex) {
System.err.println("Cannot find the database driver classes.");
System.err.println(ex);
}
catch (SQLException ex) {
System.err.println("Cannot connect to this database.");
System.err.println(ex);
}
}
catch(Exception e) {
e.printStackTrace();
}
报错信息如下:
java.sql.SQLException: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.lang.NumberFormatException)