简体   繁体   English

需要帮助以使用Eclipse和GWT App Engine连接到Google Cloud SQL

[英]Need help to connect to google Cloud SQL using Eclipse and GWT App Engine

I'm trying since days to connect my GWT Project to a google cloud SQL Database. 自几天以来,我一直在尝试将GWT项目连接到Google云端SQL数据库。 I am using jdbc and when I run this class as a Java class on a local DB or on my cloud SQL db it works perfect. 我正在使用jdbc,当我在本地数据库或云SQL数据库上以Java类的形式运行此类时,它可以完美运行。

package com.google.gwt.timecalc.server;

import java.io.IOException;
import java.sql.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.rdbms.AppEngineDriver;
import java.sql.*;
import com.google.cloud.sql.Driver;
public class ConnectionDB1 {

  static Connection con = null;
  static Statement stmt = null;
  static ResultSet rs = null;

  public static void main(String args[]) throws SQLException{

    DriverManager.registerDriver(new com.google.cloud.sql.Driver());
    try{
      // works local
      con = DriverManager.getConnection("jdbc:mysql://localhost/filme","root","admin" );                

      stmt = con.createStatement();

      rs = stmt.executeQuery("SELECT * FROM test");


      while ( rs.next() ){
        System.out.println("Id:                "+rs.getString(1));
        System.out.println("Name:           "+rs.getString(2));
      }

      rs.close();
      stmt.close();
      con.close();
    }

    catch ( SQLException e ){
      e.printStackTrace();
      System.exit(1);
    }   

  }
}

When I try to do it with my GWT Application it wont work. 当我尝试使用GWT应用程序执行此操作时,它将无法正常工作。 I work with Requestfactory btw. 我与Requestfactory btw合作。 I cannot even get the Connection to the cloud SQL DB like shown here . 我什至无法获得与此处所示的云SQL DB的连接。

Thats what I get the same error like here 那就是我在这里得到同样的错误

I worked through the google tutorial to create a new Web App with cloud sql. 我完成了google教程,使用Cloud sql创建了一个新的Web应用程序。 I also saw this but it didn't solve my problem. 我也看到了,但这并不能解决我的问题。 I also checked the google tutorials and I saw the example here: https://developers.google.com/appengine/docs/java/gettingstarted/creating Today I tried the connection turning off my firewall and antivirus but it didn't work. 我还查看了google教程,并在这里看到了示例: https : //developers.google.com/appengine/docs/java/gettingstarted/creating今天,我尝试关闭防火墙和防病毒软件的连接,但是没有用。

Any help on this would be really appreciated. 任何帮助,将不胜感激。 Thanks in advance. 提前致谢。

After being new to this myself, and struggling with the process, I would recommend following the process here: (https://developers.google.com/appengine/docs/java/cloud-sql/developers-guide) 在对自己不熟悉之后,并为这个过程苦苦挣扎,我建议在这里遵循以下过程:(https://developers.google.com/appengine/docs/java/cloud-sql/developers-guide)

It specifically was how I was able to connect, and goes through the process of registering the JDBC driver and then moving on. 具体来说,这就是我能够进行连接的方式,并完成了注册JDBC驱动程序然后继续进行的过程。

I spent hours trying to implement a slightly modified version of the initial python hello world and guestbook. 我花了几个小时来尝试实现最初的python hello world和guestbook的稍微修改的版本。 I cannot recommend enough just doing exactly as they suggest with identical file names where possible. 我不能推荐尽可能完全按照他们建议的方式使用相同文件名的方式。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Google App Engine Eclipse插件连接到Cloud SQL - Connect Google App Engine Eclipse Plugin to Cloud SQL 使用Google App Engine端点连接到Cloud SQL - Connect to Cloud SQL with Google App Engine Endpoint 在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 和云 sql :: 无法在 Google 云 sql(我的 sql)中连接 Spring boot 应用程序 - Google APP Engine and cloud sql :: Unable to connect Spring boot app in Google cloud sql (my sql) Spring 启动应用程序在部署到 Google App Engine 时无法连接到 Google Cloud SQL (PostgreSQL) - Spring Boot app can't connect to Google Cloud SQL (PostgreSQL) when deploying to Google App Engine 需要帮助进行翻新连接到Google App Engine - Need Help Connecting to Google App Engine With Retrofit 无法从Google App Engine(春​​季启动应用)连接到Google Cloud SQL(第二代) - Can not connect to google cloud sql(second generation) from google app engine(spring boot app) 使用Eclipse将MySQL与Google App Engine连接 - Connect MySQL with Google App Engine with Eclipse Google Cloud SQL和Google App Engine - Google Cloud sql and Google app engine 如何使用谷歌eclipse插件创建具有应用程序引擎模块的gwt gae - how to create gwt gae with app engine modules using google eclipse plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM