【发布时间】:2015-07-18 00:50:20
【问题描述】:
当我在本地连接到 Google MySQL 帐户时,它会从云 MySQL 表中检索记录。但是当我在生产环境中部署我的应用程序时,记录不会出现,但会出现 200 OK。
我已经试过了
String url = null;
try {
if (SystemProperty.environment.value() ==
SystemProperty.Environment.Value.Production) {
// Load the class that provides the new "jdbc:google:mysql://" prefix.
Class.forName("com.mysql.jdbc.GoogleDriver");
url = "jdbc:google:mysql://your-project-id:your-instance-name/guestbook?user=root";
} else {
// Local MySQL instance to use during development.
Class.forName("com.mysql.jdbc.Driver");
url = "jdbc:mysql://127.0.0.1:3306/guestbook?user=root";
// Alternatively, connect to a Google Cloud SQL instance using:
// jdbc:mysql://pi-address-of-google-cloud-sql-instance:3306/guestbook?user=root
}
} catch (Exception e) {
e.printStackTrace();
return;
}
我已经启用了使用 java 1.7 版本的连接器
【问题讨论】:
标签: java mysql google-app-engine cloud google-cloud-storage