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

谁说胖子不能爱 提交于 2019-11-27 09:35:53
Vadim

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!