1

When the client connects to MySQL, it throws the below exception

Last packet sent to the server was 0 ms ago.
        at sun.reflect.GeneratedConstructorAccessor112.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.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
        at sun.reflect.GeneratedConstructorAccessor110.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:302)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
        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.ConnectionPool.getConnection(ConnectionPool.java:211)
        at org.logicalcobwebs.proxool.ProxoolDriver.connect(ProxoolDriver.java:89)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:207)
        at com.chinaren.tools.MysqlConnectionPools.getConnection(MysqlConnectionPools.java:652)
        ..........
Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:525)
        at java.net.Socket.connect(Socket.java:475)
        at java.net.Socket.<init>(Socket.java:372)
        at java.net.Socket.<init>(Socket.java:215)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2026)
        ... 51 more
  1. the client can ping dbServer is OK
  2. the client can telnet dbServer:port is OK
  3. the same code on my computer connection to dbServer is OK

Is this the 8 hours problem? What is the cause?

2
  • What is it about 8 hours that you mentioned? Commented Jul 12, 2012 at 13:20
  • @Olaf a connection is idle 8 hours(default),MySQL Server will kill the connection Commented Jul 24, 2012 at 10:10

1 Answer 1

2

java.net.ConnectException: Connection refused: The connection is refused. This happens on a low level and means that the port is not open or the connection is actively refused by a firewall. Check if the JDBC URL and/or DataSource configuration actually uses the hostname/IP and port that it should use.

Also is the client actually pinging and telnetting from the same computer as this application is running on?

Sign up to request clarification or add additional context in comments.

1 Comment

@Rotteveel yes,on same computer!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.