I have a Java/Jetty based appengine project that successfully connects to Google cloud MySql server when using TCP connection with JDBC, BUT fails to connect to the same server when trying to make it through Instance name and JDBC socketFactory. the error I am getting in the GCP debug console:
"Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The >driver has not received any packets from the server."
try {
Class.forName("com.mysql.jdbc.GoogleDriver");
String url= String.format("jdbc:google:mysql:///"
+ "MY_DB_NAME" + "?"
+ "cloudSqlInstance=%s&"
+ "socketFactory=%s&"
+ "useSSL=false",
"PROJECT-ID:ZONE:INSTANCE_NAME",
"com.google.cloud.sql.mysql.SocketFactory");
return DriverManager.getConnection(url, USER_NAME, USER_PASSWORD);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}