本文介绍了无法从Google App Engine连接Google Cloud sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法从Google App引擎连接Google Cloud sql

not able to connect google cloud sql from google app engine

获取logMessage:"[

gettinglogMessage: "[

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>

推荐答案

似乎设置与数据库的连接的方式可能有问题.请确保:

It seems that something might be wrong with the way you are setting up the connection to the database.Please make sure that:

  • 已设置用于从App Engine访问Cloud SQL的正确服务帐户(如果App Engine应用程序和Cloud SQL实例位于不同的Google Cloud Platform项目中)
  • 您已经在Cloud SQL中创建了数据库
  • 您已将所有正确的参数值(Cloud SQL实例连接名称,数据库,用户和密码)添加到pom.xml文件.
  • 您正在创建连接URL,并以与此示例
  • 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)
  • You have an already created database in Cloud SQL
  • You have added all the correct parameter values (Cloud SQL instance connection name, database, user, and password) to the pom.xml file.
  • You are creating a connection URL and establishing a connection to the database in the same way it is done in this example

这篇关于无法从Google App Engine连接Google Cloud sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 03:36