gpt4 book ai didi

google-app-engine - 将 GAE/J 和 Google Cloud SQL 与多个项目一起使用时发生异常

转载 作者:太空宇宙 更新时间:2023-11-03 15:36:30 25 4
gpt4 key购买 nike

发生以下异常。

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:33)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:350)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2416)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2450)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2235)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:818)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
Caused by: java.net.SocketException: Unable to open connection to the instance: project-A:dba
at com.mysql.jdbc.GoogleCloudSqlSocket.<init>(GoogleCloudSqlSocket.java:48)
at com.mysql.jdbc.GoogleCloudSqlSocketFactory.connect(GoogleCloudSqlSocketFactory.java:81)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
... 44 more
Caused by: java.io.FileNotFoundException: /cloudsql/project-A:dba(No such file or directory)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at java.io.RandomAccessFile.<init>(RandomAccessFile...(length 8379)

我有两个 GAE/J 项目,都引用相同的谷歌云 sql 实例。例如)

  • 项目-A(gae/j) 使用项目-A:dba(cloudsql)
  • 项目-B(gae/j) 使用项目-A:dba(cloudsql)

在project-B中出现了这样的异常。

db connection setting is following.
////(in project-B's java file)//////
String url = "jdbc:google:mysql://"+ "project-B" + ":db/db1";
Connection con = DriverManager.getConnection(url, properties);
////

这是bug?还是有什么错误?

最佳答案

如果两个项目的 Cloud SQL 实例相同,则用作实例限定符的“项目 X”对于两个应用程序必须相同。这是在其下创建 Cloud SQL 实例的项目名称。

数据库主机是built in Java作为“jdbc:google:mysql://your-project-id:your-instance-name/”

根据您的示例,它将是“project-A:db/”。

不要忘记授权您的项目 B 应用访问 Cloud SQL 实例。

关于google-app-engine - 将 GAE/J 和 Google Cloud SQL 与多个项目一起使用时发生异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26030351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com