Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google cloud sql connection issue from App engine server

Hi Team, 

  Recently we have upgraded cloud mysql instance version from 5.7 to 8 then upgraded mysql-connector jar version to 9.2.0 and mysql-socket-factory-connector jar version to 8-1.23.1 with these changes I'm able to connect the new version from my local machine server using cloud proxy connection but when I deploy the same build in GCP app engine standard server its throwing the below error log in app engine server ...

javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.7.13.v20230724-7ffb888abf): org.eclipse.persistence.exceptions.DatabaseException Exception Description: Unable to acquire a connection from driver [com.mysql.cj.jdbc.Driver], user [root] and URL [jdbc:google:mysql://google.com:cts-gps:us-central1:****/***db?user=root]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform

and below error in databse log ..

[MY-010914] [Server] Aborted connection 36362 to db: '****db' user: 'root' host: 'cloudsqlproxy~34.96.47.0' (Got an error reading communication packets)

I'm using the latest driver class but still could not understand why its failing in cloud environment ..?

any solution or suggestions would be appreciated

 

 

Solved Solved
0 3 591
1 ACCEPTED SOLUTION

This issue is resolved by changing the cloud databse url  and using jdbc-socket-factory-core-1.24.0 jar and its dependencies 
Old cloud url :- jdbc:mysql://google.com:******:us-central1:Instancename/DBname?autoReconnect=true?useUnicode=yes&characterEncoding=UTF-8;useSSL=false;socketFactory=com.google.cloud.sql.mysql.SocketFactory
New cloud url :- jdbc:mysql://google.com/DBname?cloudSqlInstance=google.com:****:us-central1:Instancename&socketFactory=com.google.cloud.sql.mysql.SocketFactory

View solution in original post

3 REPLIES 3