1

I got a project to upgrade and it is using h2 DB with jdbc driver. During the build I have a systematic error on connection:

Exception in thread "main" org.h2.jdbc.JdbcSQLException: Connection is broken: "Connection refused: connect" [90067-147]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:156)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:380)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:271)
at org.h2.engine.SessionRemote.createSession(SessionRemote.java:265)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:72)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

I don't see why the connection is refused, the server is well started on the same URL, PORT and DB as the one requested.

The server is well started, but the error happen when I want to open the connection:

Connection connection = DriverManager.getConnection(DBURL, DBUSER, DBPWD + " " + DB_PWD);

Any idea about what can be the cause?

Update: This problem was not related to the firewalls but mainly to the server DB path.

Hisham
  • 21
  • 1
  • 5
  • Possible duplicate of [What can be the reasons of connection refused errors?](http://stackoverflow.com/questions/2333400/what-can-be-the-reasons-of-connection-refused-errors) – Arpit Aggarwal Oct 02 '15 at 11:35
  • Can you please share the entire stack trace? Are there any others except this one? What does *systematic* mean in this context, does the error occur constantly or does the exception occur consistently at specific intervals of time? – Filip Oct 02 '15 at 11:48
  • According to the error code `90067-147`, you are using a very old version of H2: version 1.2.147 from 2010-11-21. You should upgrade to a more recent version. – Thomas Mueller Oct 02 '15 at 14:09
  • I upgraded the version, error now is :Connection refused: connect: localhost" [90067-189] – Hisham Oct 02 '15 at 17:01
  • Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) – Hisham Oct 02 '15 at 17:07
  • at org.h2.util.NetUtils.createSocket(NetUtils.java:122) at org.h2.util.NetUtils.createSocket(NetUtils.java:102) at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114) at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:448) – Hisham Oct 02 '15 at 17:07
  • I'm using this path for the server start: jdbc:h2:tcp://localhost:9095/testdb;CIPHER=AES;IFEXISTS=TRUE – Hisham Oct 03 '15 at 09:13
  • Problem solved, the version update was a good step, I found an issue with the db path, I update it //localhost/./testdb and now everything is ok. Thanks all. – Hisham Oct 03 '15 at 14:33
  • I am struggling with the same issue. I am Spring beginner and I do not understand how you solved the problem. Could you explain please? – Dewey Banks Sep 16 '17 at 03:53

0 Answers0