1
我知道這個問題已經討論了很多次,但我無法在我的Java應用程序和MySQL服務器之間建立連接。Java和MYSQL服務器之間的連接
我用代碼形式教程:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JDBCTest{
private Connection conn = null;
public void connect(){
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("test");
conn = DriverManager.getConnection("jdbc:mysql://mysql.***.***.**:3306/******","*******","top_secret_password");
System.out.println("test2");
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " ex.getMessage());
System.out.println("SQLState: " ex.getSQLState());
System.out.println("VendorError: " ex.getErrorCode());
}catch(Exception e){e.printStackTrace();}
}
}
錯誤所發生的是:
test
SQLException: 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.
SQLState: 08S01
VendorError: 0
你有任何想法如何解決這個問題?
貌似http://stackoverflow.com/questions/2121829/java-db-communications-link-failure完全相同的副本 – Barend 2012-03-31 07:25:11