0

I want to connect to my google cloud db using the following code.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://google/testDb?cloudSqlInstance=testDb:us-central1:testInst01&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory" />
    <property name="username" value="root" />
    <property name="password" value="password" />   
</bean>

I used this url format after reading this answer: https://stackoverflow.com/a/37646496/2399720

My application builds and updates to the google app engine ok and the home page loads but whenever I try to do something that uses the db I get this error:

HTTP ERROR: 500
org.springframework.web.util.NestedServletException: Request processing     failed;
nested exception is 
org.springframework.orm.jpa.JpaSystemException: Could not open connection;
nested exception is 
org.hibernate.exception.GenericJDBCException

I feel like the url I'm using may be wrong and I've tried a few suggestions but they all get the same error. Thanks for taking a look!!

edit: some notes, I'm using a google flexible environment and a 2nd generation db

Community
  • 1
  • 1
sef9110
  • 153
  • 2
  • 10
  • Is your project-id really the same as your database name "testDb" (or something it represents)? That instance connection name in the URL can be found in the Cloud SQL instance details page in Google Cloud Console. – Herman Sep 04 '16 at 17:20
  • Yes, I copied the Instance Connection Name from the Cloud SQL dashboard. Thanks! – sef9110 Sep 04 '16 at 18:13

0 Answers0