不能谷歌云SQL从谷歌应用程序引擎连接(not able to connect google clo

2019-11-04 17:45发布

不能谷歌云SQL从谷歌应用程序引擎连接

得到的LogMessage:“[

j~gcp-ws-203608/20180510t123822.409615356828549281].<stdout>: 2018-05-10 07:20:08.036 ERROR 1 --- [Request5396402F] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_112-google-v7]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_112-google-v7]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_112-google-v7]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_112-google-v7]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[jdbc-mysql-connector.jar:na]
    at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[jdbc-mysql-connector.jar:na]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014) ~[jdbc-mysql-connector.jar:na]

依赖使用:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> 

<dependency>
  <groupId>com.google.cloud.sql</groupId>
  <artifactId>mysql-socket-factory-connector-j-6</artifactId>
  <version>1.0.5</version>
</dependency>

Answer 1:

看来,事情可能是你错了的人设定与数据库的连接方式。 请确保:

  • 从App Engine的访问Cloud SQL之后,适当的服务帐户设置(如果App Engine应用程序和云SQL实例都在不同的谷歌云平台项目)
  • 你有云SQL已创建的数据库
  • 添加了所有正确的参数值(云SQL实例连接名,数据库,用户和密码) pom.xml文件。
  • 您正在创建一个连接URL,并建立以同样的方式到数据库的连接,它是在做这个例子


文章来源: not able to connect google cloud sql from google app engine