v.recordId
从本地Java主程序通过Java连接云sql时遇到此错误
这是我的代码:
> java.lang.NoSuchMethodError: com.google.api.client.googleapis.auth.oauth2.GoogleCredential.getApplicationDefault()Lcom/google/api/client/googleapis/auth/oauth2/GoogleCredential
我有我的pom文件。
public static void main(String[] args) throws SQLNonTransientConnectionException,
IOException, SQLException {
String instanceConnectionName = "*******";
String databaseName = "******";
String IP_of_instance = "*****";
String username = "***";
String password = "******";
String jdbcUrl = String.format(
"jdbc:mysql://%s/%s?cloudSqlInstance=%s"
+ "&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false",
IP_of_instance,
databaseName,
instanceConnectionName);
Connection connection = DriverManager.getConnection(jdbcUrl, username, password);
try (Statement statement = connection.createStatement()) {
ResultSet resultSet = statement.executeQuery("SHOW TABLES");
while (resultSet.next()) {
System.out.println(resultSet.getString(1));
}
} catch (Exception e) {
e.printStackTrace();
}
}