我尝试寻找解决方案,但该网站上的问题并不是我正在寻找的答案。
我尝试运行:
private static final String USERNAME= "root";
private static final String PASSWORD= "root";
private static final String CONN_STRING= "jdbc:mysql//localhost:3306/java";
conn Connection = null;
try{
conn = DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD);
System.out.println("Connected");
} catch (SQLException e){
System.err.println(e);
}
我拥有 8.0.12 版本的服务器和连接器。
最佳答案
您的 JDBC URL 应遵循 jdbc:mysql://localhost/test
格式,如
7.1 Connecting to MySQL Using the JDBC DriverManager Interface文档。
您在 mysql
部分后面缺少一个分号,它应该是
private static final String CONN_STRING = "jdbc:mysql://localhost:3306/java";
关于java.sql.SQLException : No suitable driver found for jdbc:mysql//127. 0.0.1 :3306/java Error - JDK 1. 8,mysql连接器8.0.12,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52672230/