最近开始重新学习,新建了两台虚拟机,安装上weblogic之后,新建数据源,本来打算连接到本地windows的MySQl数据库,可是却报了连接超时的错误:
消息图标 - 错误 连接测试失败。
消息图标 - 错误 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.
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
com.mysql.jdbc.Util.handleNewInstance(Util.java:395)
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1101)
com.mysql.jdbc.MysqlIO.(MysqlIO.java:350)
com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2392)
com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2429)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2214)
com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:797)
com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:31)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
com.mysql.jdbc.Util.handleNewInstance(Util.java:395)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:383)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
weblogic.jdbc.common.internal.DataSourceUtil.testConnection0(DataSourceUtil.java:371)
…
,这次第一反应就是也是防火墙的问题,然后就新建了入站规则,允许访问3306端口
再次测试,又失败了:
消息图标 - 错误 连接测试失败。
消息图标 - 错误 null, message from server: "Host ‘m104’ is not allowed to connect to this MySQL server"
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1058)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:972)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:958)
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1104)
com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2396)
com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2429)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2214)
com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:797)
com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:31)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
com.mysql.jdbc.Util.handleNewInstance(Util.java:395)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:383)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
weblogic.jdbc.common.internal.DataSourceUtil.testConnection0(DataSourceUtil.java:371)
weblogic.jdbc.common.internal.DataSourceUtil.access$000(DataSourceUtil.java:24)
weblogic.jdbc.common.internal.DataSourceUtil$1.run(DataSourceUtil.java:285)
java.security.AccessController.doPrivileged(Native Method)
…
不过万幸的是这次的报错信息和之前不一样,也就是说明对防火墙的修改是有效的,在网上查了一下,说是权限问题,sys数据库中user表中的配置限制远程连接,然后再次修改user表,把root用户的数据复制一条,修改Host字段为%,保存。
执行flush privileges命令,刷新权限,再次测试连接。这次总算连接成功了。