简体   繁体   English

无法从Google App Engine连接Google Cloud sql

[英]not able to connect google cloud sql from google app engine

not able to connect google cloud sql from google app engine 无法从Google App Engine连接Google Cloud sql

getting logMessage: "[ 正在获取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 used: 使用的依赖项:

<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>

It seems that something might be wrong with the way you are setting up the connection to the database. 您建立与数据库的连接的方式似乎有些问题。 Please make sure that: 请确保:

  • The proper service account for accessing Cloud SQL from App Engine is setup (if the App Engine application and the Cloud SQL instance are in different Google Cloud Platform projects) 设置了用于从App Engine访问Cloud SQL的正确服务帐户(如果App Engine应用程序和Cloud SQL实例位于不同的Google Cloud Platform项目中)
  • You have an already created database in Cloud SQL 您已经在Cloud SQL中创建了数据库
  • You have added all the correct parameter values (Cloud SQL instance connection name, database, user, and password) to the pom.xml file. 您已将所有正确的参数值(Cloud SQL实例连接名称,数据库,用户和密码)添加到pom.xml文件。
  • You are creating a connection URL and establishing a connection to the database in the same way it is done in this example 您正在创建连接URL并以与本示例相同的方式建立与数据库的连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM