try {
String connectionURL = "jdbc:mysql://sql4.000webhost.com/a7291194_xxx";
Connection connection = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "a7291194_xxx", "xxx");
if(!connection.isClosed())
System.out.println("Successfully connected to " + "MySQL server using TCP/IP...");
connection.close();
}catch(Exception ex){
System.out.println("Unable to connect to database"+ex);
}
使用以下连接器代码,我尝试连接 000webhost.com 上的数据库,但它给了我一个错误:
CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
我第一次尽力而为,因为我对虚拟主机完全陌生,所以请帮助我提前谢谢!