0

not able to connect google cloud sql from google app engine

getting 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>
Avinash Garg
  • 1,374
  • 14
  • 18

1 Answers1

0

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)
  • 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
Philipp Sh
  • 967
  • 5
  • 11