使用proxool数据库连接池,平常都好好的,今天出现这个异常:
2014-03-19 14:41:05 [ERROR] [org.logicalcobwebs.proxool.Prototyper-sweep] Prototype
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
at sun.reflect.GeneratedConstructorAccessor51.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2359)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:284)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.logicalcobwebs.proxool.DefaultConnectionBuilder.buildConnection(DefaultConnectionBuilder.java:39)
at org.logicalcobwebs.proxool.Prototyper.buildConnection(Prototyper.java:159)
at org.logicalcobwebs.proxool.Prototyper.sweep(Prototyper.java:102)
at org.logicalcobwebs.proxool.PrototyperThread.run(PrototyperThread.java:44)
Caused by: 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.GeneratedConstructorAccessor28.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
... 14 more
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:218)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
... 15 more
提示无法创建数据库连接,解决方案:
1,ping一下数据库的ip,看看是不是还通着,是不是写错了(针对使用内网ip的,看看内网ip是不是还通着,否则就是内网网线断了)
2,看看mysql服务器的防火墙是不是开着
3,看看端口3306是不是被占用了
4,看看用户名和密码是不是写错了
5,重启mysql试一试吧
6,继续google吧 ,找到方案了回个贴吧,哈哈,谢谢
相关推荐
在应用程序中调用不同服务时,经常会遇到No route to host程序异常的问题。下文分享该问题的排查过程与解决方法。
格式化namenode时 报错 No Route to Host from node1/192.168.3.101 to hadoop05:8485 failed on socket timeout exception: java.net.NoRouteToHostException: No route to host解决方案 一、报错信息概要: 在配置...
java.net.NoRouteToHostException: No route to host 是 Hadoop 中的常见问题,主要是由于网络连接问题。解决方法是停止 iptables 服务,例如使用 `sudo /etc/init.d/iptables stop` 命令。 更改 namenode 后,在 ...
- **错误现象1:java.net.NoRouteToHostException: No route to host** - 原因:此错误通常由于防火墙阻止了通信导致。 - 解决方法:关闭Master服务器上的防火墙,例如在Linux环境下使用`chkconfig iptables off`...
- 在执行DNS查询时,可能会遇到各种异常,如`UnknownHostException`(无法找到主机)、`NoRouteToHostException`(无路由到主机)、`SocketTimeoutException`(超时)等。这些异常都需要适当地捕获和处理。 6. **...
Java网络编程中可能遇到的异常包括`BindException`、`ConnectException`、`MalformedURLException`、`NoRouteToHostException`、`ProtocolException`、`SocketException`、`UnknownHostException`和`...
如`ConnectException`表示连接失败,`SocketException`通常与网络连接有关,`MalformedURLException`则是在解析URL时格式错误,`UnknownHostException`是无法解析主机名,`NoRouteToHostException`表示无法找到到...
在Java中,网络编程涉及异常处理,如`BindException`(绑定地址或端口失败)、`ConnectException`(连接失败)、`MalformedURLException`(URL格式错误)、`NoRouteToHostException`(找不到到目的地的路由)、`...