0
votes

I am trying to connect to some database located in Google Cloud SQL from a java web application deployed on AWS Elasic Beanstalk (with Eclipse), using the JDBC method.

String url = ConfigUtilities.getProperty("DATABASE_CONNN_URL_" + mode);
conn = DriverManager.getConnection(url, ConfigUtilities.getProperty("USERNAME_DB_" + mode),
                ConfigUtilities.getProperty("PASSWORD_DB_" + mode));

The url looks like this

DATABASE_CONNN_URL_PRODUCTION=jdbc:google:mysql://project-name:europe-west1:instance-name/db-name

I have the following jar attached: mysql-connector-java-6.0.6.jar (located in lib folder under WEB-INF).

I get the following error

No suitable driver found for jdbc:google:mysql://project-name:europe-west1:instance-name/db-name

The same application deployed in App Engine works.

1

1 Answers

0
votes

snippet from Connecting to Cloud SQL from External Applications The JDBC socket factory provides an alternative to the client-side proxy software, and requires the Cloud SQL API to be enabled, just as the proxy does. It authenticates with Cloud SDK credentials, so the Cloud SDK must be installed and authenticated.

examples/compute-engine/src/main/java/com/google/cloud/sql/mysql/example/ListTables.java

String jdbcUrl = String.format( "jdbc:mysql://google/%s?cloudSqlInstance=%s&" + "socketFactory=com.google.cloud.sql.mysql.SocketFactory", databaseName, instanceConnectionName);

Connection connection = DriverManager.getConnection(jdbcUrl, username, password);