我尝试使用数据库连接的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