无法使用MySQL驱动程序创建JDBC连接。面对
“ com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException”
这是我正在使用的Java代码
public static Connection getConnection() throws ClassNotFoundException, SQLException {
Connection con = null;
try {
Class.forName(DRIVERNAME);
con = DriverManager.getConnection(URL, USERNAME, PASSWORD);
} catch (ClassNotFoundException e) {
System.out.println("MySQLUtil | getConnection() | ClassNotFoundException | "+e.getMessage());
e.printStackTrace();
} catch (Exception e) {
System.out.println("MySQLUtil | getConnection() | Exception | "+e.getMessage());
e.printStackTrace();
}
return con;
}