我正在尝试连接到本地MySQL服务器,但是在安装xampp之后无法做到这一点
这是Java代码
public class Testjdbc {
public static void main(String[] args) {
String jdbcUrl = "jdbc:mysql://localhost:3306/hb-01-one-to-one-uni?
userSSL=false";
String user = "hbstudent";
String pass = "hbstudent";
try {
System.out.println("Connecting to database... " + jdbcUrl);
Connection connection =
DriverManager.getConnection(jdbcUrl, user, pass);
System.out.println("Connection Successfull");
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
和错误:
Connecting to database... jdbc:mysql://localhost:3306/hb-01-one-to-one-uni?
userSSL=false
com.mysql.cj.jdbc.exceptions.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.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)