Java / GWT / MySQL:连接被拒绝了?

时间:2011-12-01 01:03:33

标签: java mysql gwt

我正在开发一个GWT Web应用程序,并尝试从我的RemoteServiceServlet实现(对于rpc)连接到mysql数据库。

服务器运行,我可以从我工作的机器连接到数据库。出于测试目的,我编写了一个只连接到数据库的小程序。这有效:

Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.106:3306/dbname", "dbuser", "dbpasswd");

但是我的gwt应用程序中的相同行失败了大约100行堆栈跟踪,这是“原因”:

Caused by: java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.106:3306 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndThrowIt(StandardSocketFactory.java:408)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:269)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
... 55 more

现在我的问题:为什么?

编辑:用于测试我使用chrome和gwt插件的开发模式

edit2:崩溃的代码部分:

public DataLinkImpl() {
Connection tmpConnection = null;
try {
  Class.forName("com.mysql.jdbc.Driver");
  tmpConnection = DriverManager.getConnection("jdbc:mysql://192.168.0.106:3306/dbname", "dbuser", "dbpasswd");
} catch (ClassNotFoundException e) {
  System.err.println("jdbc driver class not found");
} catch (SQLException e) {
  System.err.println("could not establish database connection");
  e.printStackTrace();
  e.getNextException().printStackTrace();
} finally {
  connection = tmpConnection;
}
}

使用以下stacktrace:

could not establish database connection
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:112)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:120)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:112)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:120)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at de.eikecochu.gwt.awidb.server.DataLinkImpl.<init>(DataLinkImpl.java:23)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.106:3306 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndThrowIt(StandardSocketFactory.java:408)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:269)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
... 55 more
01.12.2011 02:33:09 com.google.appengine.tools.development.ApiProxyLocalImpl log
SCHWERWIEGEND: javax.servlet.ServletContext log: unavailable

java.lang.NullPointerException
at de.eikecochu.gwt.awidb.server.DataLinkImpl.<init>(DataLinkImpl.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

01.12.2011 02:33:09 com.google.apphosting.utils.jetty.JettyLogger warn
WARNUNG: /awidb/datalink
java.lang.NullPointerException
at de.eikecochu.gwt.awidb.server.DataLinkImpl.<init>(DataLinkImpl.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

edit3:我在/Library/Java/.../security/java.policy文件中添加了权限:

grant {
    permission java.net.SocketPermission "192.168.0.106:3306", "connect,resolve";
}

但仍然相同,我无法连接到数据库。我也尝试直接在db所在的机器上执行它,所以我在tomcat中部署了它(在那里添加了相同的权限),但仍然没有去。 WTF ??

edit4:为了证实这一点,我写了一个非常简单的网络应用程序:

EntryPoint类:

package de.eikecochu.gwt.gwttest.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

public class GWTTest implements EntryPoint {
  private TestServiceAsync testservice = GWT.create(TestService.class);
  @Override
  public void onModuleLoad() {
    Button b = new Button("test");
    RootPanel.get("container").add(b);
    b.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        testservice.echo("test", new AsyncCallback<String>() {
          @Override
          public void onFailure(Throwable caught) {
            RootPanel.get("container").add(new Label("error"));
          }
          @Override
          public void onSuccess(String result) {
            RootPanel.get("container").add(new Label(result));
          }
        });
      }
    });
  }
}

远程服务接口:

package de.eikecochu.gwt.gwttest.client;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("testservice")
public interface TestService extends RemoteService {

  String echo(String s);

}

远程服务异步接口:

package de.eikecochu.gwt.gwttest.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface TestServiceAsync {

  void echo(String s, AsyncCallback<String> callback);

}

RemoteServiceServlet实施:

package de.eikecochu.gwt.gwttest.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import de.eikecochu.gwt.gwttest.client.TestService;

public class TestServiceImpl extends RemoteServiceServlet implements
    TestService {
  private static final long serialVersionUID = 1L;

  private final Connection connect() {
    String driver = "com.mysql.jdbc.Driver";
    String dblink = "jdbc:mysql://192.168.0.106:3306/";
    String dbname = "dbname";
    String dbuser = "dbuser";
    String dbpass = "dbpass";
    try {
      Class.forName(driver).newInstance();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    Connection conn = null;
    try {
      conn = DriverManager.getConnection(dblink + dbname, dbuser, dbpass);
    } catch (SQLException e) {
      System.err.println("mysql connection error: ");
      e.printStackTrace();
    }
    return conn;
  }

  @Override
  public String echo(String s) {
    Connection c = connect();
    return s;
  }

}

这也不起作用。不在我的机器上,而不在localhost(db所在的位置)上。再次出现相同的错误(AccessControlException bla bla)。

edit5:我试图在我的服务器上直接执行我的应用程序,这意味着:我在服务器上安装了eclipse和gwt工具,并在chrome / development模式下在本地执行。还是一样的错误。我觉得我的mysql / ubuntu有错误的配置,或者我从根本上做错了什么。通常,连接数据库应该很容易,是吗?我的意思是,没有数据库的网站是什么......

edit6:正如巴巴建议的那样,我试着设定     System.setSecurityManager(NULL);

在连接到数据库之前,在我的RemoteServlet中

。它抛出以下错误(缩写):

java.security.AccessControlException: access denied (java.lang.RuntimePermission setSecurityManager)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:252)
at java.lang.System.setSecurityManager0(System.java:273)
at java.lang.System.setSecurityManager(System.java:264)

所以我似乎安装了一个SecurityManager。

另外,我尝试使用telnet访问我的数据库。起初,我的连接被拒绝,但我将我的mysql-bind地址更改为我的服务器的IP(192.168.0.106),并按照此处的步骤进行操作:http://ubuntu-commands.blogspot.com/2008/11/how-do-i-enable-remote-access-to-mysql.html

现在我telnet 192.168.0.106 3306时会出现奇怪的符号:

eikes-macbook-air:~ eike$ telnet 192.168.0.106 3306
Trying 192.168.0.106...
Connected to eike-server.speedport.ip.
Escape character is '^]'.
=
5.1.58-1ubuntu1(b5|529h~!dYpI\rHP:qKc

ot packets out of orderConnection closed by foreign host.

这似乎是一个错误?

另外,我搜索了AccessDenied错误并找到了此链接:http://code.google.com/p/gwt-examples/wiki/project_MySQLConn#Tomcat_Setup_Notes 虽然我使用Devmode进行开发,但它完全描述了我遇到的错误。虽然遵循这些步骤没有帮助(我编辑了我的默认/Library/.../security/java.policy文件)

edit7:我安装了postgresql并设置了一个非常简单的数据库来测试连接。没有GWT它工作正常,GWT再次产生相同的错误。因此,这不是我的mysql配置的错误。我玩了一下java策略文件,没有反应。 GWT讨厌我:&lt;

edit8:我在另一台机器上尝试了postgresql和mysql(这次是win7)并在本地执行了我的gwt应用程序(在编辑策略文件之前和之后),仍然是同样的错误。这无疑是GWT的错!似乎gwt devmode不允许在任何地方做任何事情......

另一个问题:错误明确指出“java.security.AccessControlException:access denied(java.net.SocketPermission localhost resolve)”,那么为什么当我修改我的java策略文件进行连接时仍会出现这个问题,解决所需的问题端口?看来这绝对没有效果!我甚至试过授予AllPermission,也没有效果。

接下来,我找到了“gwt-log.txt”,其中列出了加载过程中的错误:

Public resources found in...
[WARN] Error processing classpath URL 'file:/C:/Program Files (x86)/eclipse/plugin/com.google.gdt.eclipse.designer.hosted.2_2_2.4.2.r37x201110201837/gwt-dev-designtime.jar'
java.net.URISyntaxException: Illegal character in path at index 16: file:/C:/Program Files (x86)/eclipse/plugins/com.google.gdt.eclipse.designer.hosted.2_2_2.4.2.r37x201110201837/gwt-dev-designtime.jar
at java.net.URI$Parser.fail(Unknown Source)

我不知道那是什么,或者它是否重要,但这不是我的错!

3 个答案:

答案 0 :(得分:6)

您已使用 Google App Engine安装了Google Eclipse插件。创建一个新的GWT项目并确保取消选择Google App Engine,然后重试。或者,从eclipse类路径中删除所有与GAE相关的jar文件。

GAE是Google提供的托管环境。它的环境非常有限。它不允许您打开套接字连接或读/写文件。数据库驱动程序打开套接字连接,因此GAE会阻止它出现安全性异常。

GWT和GAE是Google提供的两个独立产品,但Eclipse插件是相同的。不幸的是,它假设您希望将这两种产品用作项目的一部分。

答案 1 :(得分:4)

听起来像你的SecurityManager政策不允许你做你正在做的某些事情。您确定应用了java.policy文件吗?你能尝试调用`System.setSecurityManager(null);'并尝试连接到您的数据库?

如果在调用setSecurityManager期间遇到SecurityException,我觉得你有一个SecurityManager。另外,正如我上面的那个人说的那样:

  

请记住,默认情况下mysql不会监听非localhost   接口,你需要自己打开它们。

你能试着telnet到上面的地址和上面的端口,看看一切都好吗?

编辑:

我看的东西越多,我就越认为这是一个MySQL配置问题。您是否从尝试过GWT连接的同一台机器上执行纯Java代码?为什么即使你的telnet失败,你的纯Java代码也可以连接?你能再次证实这种行为吗?

答案 2 :(得分:1)

请记住,默认情况下,mysql不会侦听非localhost接口,您需要自己打开它们。