[英]Issue with connection from Google App Engine and Google Cloud SQL on production
When I connect to Google MySQL account locally, it retrieve records from cloud MySQL table. 当我在本地连接到Google MySQL帐户时,它会从云MySQL表中检索记录。 But when I deploy my application on production, records are not coming but 200 OK is coming.
但是,当我将应用程序部署到生产环境中时,记录并没有出现,但是200 OK了。
I've already tried 我已经尝试过了
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;
}
I have enable the connector using java 1.7 version 我已经使用Java 1.7版本启用了连接器
If you have not linked your App Engine's Application ID to the Authorized App Engine Applications' list for Cloud SQL instance, you may need to link those two, because only apps listed there will be allowed to access your Cloud SQL instance; 如果您尚未将App Engine的应用程序ID链接到Cloud SQL实例的“授权App Engine应用程序”列表,则可能需要链接这两者,因为只有那里列出的应用程序才可以访问您的Cloud SQL实例; and those must be located in the same region as well.
并且这些地点也必须位于同一地区。
Also, you should add 另外,您应该添加
<use-google-connector-j>true</use-google-connector-j>
in appengine-web.xml. 在appengine-web.xml中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.