简体   繁体   English

生产中Google App Engine和Google Cloud SQL的连接出现问题

[英]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.

相关问题 是否可以将JPA连接池与Google App Engine和Cloud SQL一起使用? - Is it possible to use a JPA connection pool with Google App Engine and Cloud SQL? Google Cloud SQL和Google App Engine - Google Cloud sql and Google app engine Google Cloud App Engine与Postgresql的连接被拒绝 - google cloud app engine to postgresql connection refused 部署后的Google App Engine和Cloud SQL - Google App Engine and Cloud SQL when deployed 使用Google App Engine端点连接到Cloud SQL - Connect to Cloud SQL with Google App Engine Endpoint Google应用引擎:分离测试和生产版本的云端点 - Google app engine: Separating test and production version of cloud endpoints 无法从Google App Engine(春​​季启动应用)连接到Google Cloud SQL(第二代) - Can not connect to google cloud sql(second generation) from google app engine(spring boot app) 在Eclipse中进行开发时无法从Google App Engine连接到Google Cloud SQL实例 - Unable to connect to Google Cloud SQL instance from Google App Engine when developing in Eclipse Google App Engine / Google Cloud SQL-检测它是MySQL还是Google Cloud SQL - Google App Engine/ Google Cloud SQL - Detect if it is MySQL or Google Cloud SQL Google APP Engine 和云 sql :: 无法在 Google 云 sql(我的 sql)中连接 Spring boot 应用程序 - Google APP Engine and cloud sql :: Unable to connect Spring boot app in Google cloud sql (my sql)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM