Reputation: 11207
I want to deploy my java spring boot application on Google cloud engine. It works well when I do not configure a db. But then when I use jpa, it just cannot find the connection. I tried multiple approached but non worked so far.
spring:
jpa:
database: MYSQL
show-sql: false
hibernate:
ddl-auto: update
datasource:
driver-class-name: com.mysql.jdbc.GoogleDrive
username: root
password: ********
url: jdbc:google:mysql://something-app:us-central1:something/something?user=root
This is the last config that I tried but it cannot find the driver. I have this in my pom.cml
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.0-beta1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.4</version>
</dependency>
Any idea of what I am doing wrong. Or example (github or other) that has it working?
stack trace:
2016-10-08 14:13:13 default[20161008t161026] java.sql.SQLException: Driver:com.google.appengine.api.rdbms.AppEngineDriver@746b25b1 returned null for URL:jdbc:google:mysql://something-app:us-central1:something/something?user=root
Upvotes: 1
Views: 1026
Reputation: 11207
I finally got it working with the following configuration.
spring:
jpa:
database: MYSQL
show-sql: false
hibernate:
ddl-auto: update
datasource:
url: jdbc:mysql://google/myproject?cloudSqlInstance=myproject-app:us-central1:myproject&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=******&password=**********
I used this in the pom.xml
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.1</version>
</dependency>
Upvotes: 1