目标:在云中运行一个独立的Java &数据库应用程序,以提高性能、可伸缩性和高可用性
应用程序详细信息
注释:云Shell与Cloud在同一个Google项目中
user@${PROJECT_ID}:~$ cd git
user@${PROJECT_ID}:~$ cd myapplication使用Maven运行应用程序会引发无法连接到Cloud数据库的异常
user@${PROJECT_ID}:~$ mvn exec:java使用不同的JDBC连接字符串和JDBC驱动程序没有帮助。
application.properties
# Use MySQL database
#etl.datasource.url=jdbc:mysql://${IP:Instance_name}/${database}?autoReconnect=true&useSSL=false
#etl.datasource.url=jdbc:google:mysql://${INSTANCE_CONNECTION_NAME}/${database}
etl.datasource.url=jdbc:mysql://google/${database}?cloudSqlInstance=${INSTANCE_CONNECTION_NAME}&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false
#etl.datasource.driver-class-name=com.mysql.jdbc.Driver
etl.datasource.driver-class-name=com.mysql.jdbc.GoogleDriver
etl.datasource.username=${user}
etl.datasource.password=${password}2017-08-03 10:40:59.477错误381 -- MyApplication.main() o.a.tomcat.jdbc.pool.ConnectionPool :无法创建池的初始连接。com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:无法创建到数据库服务器的连接。尝试重新连接3次。放弃吧。 2017-08-03 12:16:23.525错误1048 - MyApplication.main() o.a.tomcat.jdbc.pool.ConnectionPool :无法创建池的初始连接。无法从ClassLoader:java.net.URLClassLoader@13b428de;ClassLoader:java.net.URLClassLoader@13b428de加载类: com.mysql.jdbc.GoogleDriver
即使添加src/webapp/WEB/appEngine-web.xml也没有帮助。
appengine-web.xml
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<use-google-connector-j>true</use-google-connector-j>
</appengine-web-app>问题
https://stackoverflow.com/questions/45490133
复制相似问题