keeping Connection alive
От | Andreas Brandl |
---|---|
Тема | keeping Connection alive |
Дата | |
Msg-id | 943271.32.1260661401559.JavaMail.root@store1.zcs.ext.wpsrv.net обсуждение исходный текст |
Ответы |
Re: keeping Connection alive
|
Список | pgsql-jdbc |
Hi, I'm using a PostgreSQL as backend for a Java application, which may idle for quite a while (i.e. hours) and now and thenissue a query on the backend. The problem is the following exception I get when connection is apparently broken: -- snip -- org.postgresql.util.PSQLException: An I/O error occured while sending to the backend. -- snip -- What is best practice to prevent the connection from breaking, i.e. keeping the Conection alive? I'm using an instance of PGPoolingDataSource and would expect to retrieve a _valid_ Connection when calling DataSource.getConnection()(which I don't get). I even did call PGPoolingDataSource.setTcpKeepAlive(true) - same result. My first approach was to use a scheduled task and regularly check the Connection for validity ("ping") - unfortunately Connection.isValid(inttimeout) has not been implemented yet. My current workaround is a scheduled task issueing a "SELECT 1" on a regularly basis. Which I feel is not the best solution,though. I read of using a connection pool like dbcp, which I'd like to avoid: I don't need connection pooling at all, just need tohave a valid Connection even after hours of no-operation (a reconnect is ok, so no performance issue here). So, what's the best practice using the postgresql jdbc driver? I'm using PostgreSQL 8.3.8 and postgresql-8.4-701.jdbc4.jar for JDBC. Thanks alot! Best regards, Andreas
В списке pgsql-jdbc по дате отправления: