java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.GoogleDriver]

com.mysql.jdbc.GoogleDriver is designed to work for App Engine Standard Environment applications.

For Java applications running on App Engine Flexible Environment applications use the mysql-socket-factory library.

For a Maven-based application, add a dependency on the library:

<dependency>
    <groupId>com.google.cloud.sql</groupId>
    <artifactId>mysql-socket-factory</artifactId>
    <version>1.0.1</version>
</dependency>

Switch to the standard/official com.mysql.jdbc.Driver. The connection string changes from

jdbc:google:mysql://instance_name/db_name

to

jdbc:mysql://google/db_name?cloudSqlInstance=<instance_connection_name>&socketFactory=com.google.cloud.sql.mysql.SocketFactory

The value for <instance_connection_name> can be found on the Cloud SQL instance overview page in Google Cloud Console.

Note: If you are specifying the connection string in an XML file you might have to escape special characters like & to &amp;.

Note: This method doesn't work with the development line of the mysql driver (6 and above). I had to use the production 5.1.39 version.