We opened a ticket with Google support (# 52128844) but they advised us to report our issue here.
We have a MySQL instance that we could connect to from App Engine Standard running Java 8 when it was running MySQL 5.6.
The instance and App Engine are in the same project.
The instance uses a public IP address.
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql:///mydatabase");
config.setUsername("myuser");
config.setPassword("mypassword");
// Without this line throws RuntimeException Failed to get driver instance for jdbcUrl=...
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.mysql.SocketFactory");
config.addDataSourceProperty("cloudSqlInstance", "myproject:myregion:myinstance");
// Including or excluding this line makes no difference in the error
config.addDataSourceProperty("unixSocketPath", "/cloudsql/myproject:myregion:myinstance");
// Including or excluding this line makes no difference in the error
config.addDataSourceProperty("ipTypes", "PUBLIC");
HikariDataSource source = new HikariDataSource(config);
Connection conn = source.getConnection();
The line
HikariDataSource source = new HikariDataSource(config);
Throws this exception:
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server.
com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:596)
com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:582)
com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:115)
com.zaxxer.hikari.HikariDataSource.(HikariDataSource.java:81)
We opened a ticket with Google support (# 52128844) but they advised us to report our issue here.
We have a MySQL instance that we could connect to from App Engine Standard running Java 8 when it was running MySQL 5.6. The instance and App Engine are in the same project. The instance uses a public IP address.
appengine-web.xml:
We upgraded the instance in place to MySQL 8.0.
We confirmed the instance is running by connecting with MySQL Workbench.
Based on the examples here: https://cloud.google.com/sql/docs/mysql/connect-app-engine-standard And here: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java
We added dependencies:
And changed our code to:
The line
Throws this exception: