我正在尝试通过我的应用程序将数据插入到 Google Cloud mysql 数据库中,该应用程序是通过 eclipse 在 java 上构建的。这是代码:
package com.example.dao;
import java.sql.Connection;
import java.sql.DriverManager;
public class dao {
private static Connection con;
public static Connection getcon(){
try{
String instanceConnectionName = "edu-vitae1";
String databaseName = "eduvitae";
String username = "root";
String password = "edu";
String jdbcUrl = String.format(
"jdbc:mysql://google/eduvitae?cloudSqlInstance=edu-vitae1&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=root&password=root&useSSL=false",
databaseName,
instanceConnectionName);
Connection con = DriverManager.getConnection(jdbcUrl, username, password);
Class.forName("com.mysql.jdbc.GoogleDriver");
//con=DriverManager.getConnection("jdbc:google:mysql://edu-vitae1>/edu-vitae?user=root&password=root");
}
catch (Exception e) {
System.out.println(e);
}
return con;
}
}
部署项目后,我收到此错误:
java.sql.SQLException: 找不到适合 jdbc 的驱动程序:mysql://google/eduvitae?cloudSqlInstance=edu-vitae1&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=root&password=root&useSSL=false
谁能帮我解决这个问题。提前致谢
至尊宝的传说
相关分类