H2 Database (embedded) connection timeout Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of H2 Database (embedded) connection timeout without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I get the following exception when connecting to the database:

org.h2.jdbc.JdbcSQLException: Connection is broken: "connect timed out" [90067-142]
    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:326)
    at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:248)
    at org.h2.engine.SessionRemote.createSession(SessionRemote.java:214)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:111)
    at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:95)
    at org.h2.Driver.connect(Driver.java:73)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
Caused by: java.net.SocketTimeoutException: connect timed out
    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 org.h2.util.NetUtils.createSocket(NetUtils.java:109)
    at org.h2.util.NetUtils.createSocket(NetUtils.java:91)
    at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:92)
    at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:322)
    ... 38 more

The connection string looks as follows:


What can be the reason for such exception?



I guess you read the docs about the automatic mixed mode? It’s hard to say what the problem is, because for me it works. Could you post the content of the file C:UsersMichael.myadddb.lock.db ? For me it is (after connecting):

#Tue Dec 14 22:29:22 CET 2010

That means the database is open, and the client that opened it started a server on this IP address and port.

We are here to answer your question about H2 Database (embedded) connection timeout - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji