我嘗試使用數據庫連接的Java應用程序時遇到了以上消息。.com.mysql.jdbc.exception.jbbc4.communicationexception..communication鏈接失敗
com.mysql.jdbc.exceptions.jdbc4.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.
這裏我會在我的java應用程序中提到一些java代碼;我用來連接數據庫。
JDBC驅動程序名稱和數據庫URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost/SORTS";
用戶名和密碼
static final String USER = "root";
static final String PASS = null;
註冊JDBC驅動程序
Class.forName("com.mysql.jdbc.Driver");
// 「連接到所選數據庫...」
conn = DriverManager.getConnection(DB_URL, USER, PASS);
我覺得這些MySQL服務器的信息也可能是有用
current database:sorts
current user:[email protected]
Connection:localhost via TCP/IP
TCP port:3307