授权了远程访问 navicat能连接 5和8都试过都不行
报错信息
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://192.168.137.128:3306/springboot?userSSL=false";
String user = "root";
String password = "time200311";
conn = DriverManager.getConnection(url,user,password);
String sql = "select * from t_student";
stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
while (rs.next()){
System.out.println(rs.getString("name"));;
}
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 786 milliseconds ago. The last packet sent successfully to the server was 777 milliseconds ago.