当我在本地连接到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版本启用连接器
答案 0 :(得分:0)
如果您尚未将App Engine的应用程序ID链接到Cloud SQL实例的授权应用程序引擎应用程序列表,则可能需要将这两者联系起来,因为只有那里列出的应用程序才能访问您的Cloud SQL实例;那些也必须位于同一地区。
另外,你应该添加
<use-google-connector-j>true</use-google-connector-j>
在appengine-web.xml中。