We're breaking some functionality out of our app engine project and moving it to google cloud functions (GCF).
For the life of me, I can't get a db connection from the GCF. The exact same code is used in both the app engine app and GCF.
The db connection is initialized like this and this works in app engine:
String dbconn = "jdbc:mysql:///" + MYDBNAME +
"?cloudSqlInstance=" + PROJECTID + ":us-central1:" + INSTANCEID +
"&socketFactory=com.google.cloud.sql.mysql.SocketFactory;
String uid = "xxx";
String pwd = "xxx";
config.setJdbcUrl( dbconn );
config.setUsername( uid );
config.setPassword( pwd );
ConnectionPool pool = new HikariDataSource( config );
This works perfectly in app engine.
However, the GCF shows this in the logs.
Failed to get driver instance for jdbcUrl=jdbc:mysql:///MYDBNAME?cloudSqlInstance=PROJECTID:us-central1:INSTANCEID&socketFactory=com.google.cloud.sql.mysql.SocketFactory
I've also configured a SQL connection in the GCF cloud console.
And the pom.xml file contains the sql classes.
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-8</artifactId>
<version>1.13.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.33</version>
<scope>runtime</scope>
</dependency>

google-cloud-sql-jdbc-socket-factorylibrary is installed.