Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Intermittent Java PostgreSQL Connection closed  RSS feed

Gerry Scott
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Java program connects using ibatis to a PostgreSQL DB server. Most of the time, the connection is fine.

However, sometimes the connection takes very long and then I get an exception stating that the connection has been closed, although I have not closed it at all. Yet later on my program still can access the DB server normally.

The stack trace is here.

Caused by: org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(
at org.postgresql.jdbc2.AbstractJdbc2Connection.rollback(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.ibatis.common.jdbc.SimpleDataSource$SimplePooledConnection.invoke(
at com.sun.proxy.$Proxy0.rollback(Unknown Source)
at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.rollback(
at com.ibatis.sqlmap.engine.transaction.TransactionManager.end(
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(
at mblib.dao.TrxLogDAO.insertLog(
... 10 more

Thanks in advance.
A.J. Côté
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have any firewall or router between your application server and the database server?

Does ibastis use connection pooling?

You could look at sending any form of keep alive from ibatis jdbc driver to the database server anyway. Chances is this might solve your problem.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!