Re: No automatic reconnect after network error - Mailing list pgsql-jdbc

From Guy Rouillier
Subject Re: No automatic reconnect after network error
Date
Msg-id CC1CF380F4D70844B01D45982E671B230137A877@mtxexch01.add0.masergy.com
Whole thread Raw
In response to No automatic reconnect after network error  ("Markus Riehl" <mriehl@skat.com>)
List pgsql-jdbc
Markus Riehl wrote:
> Hi Markus,
>
> thanks for your answer.
>
>> Currently, the backend cannot keep the current transaction if the
>> connection breaks, so it will be rolled back.
>
> That's ok, I just want the JDBC driver to reconnect as soon as the
> connection is available again.
>
>> At least JBoss, you can use the following approach: In the Datasource
>> definition, put the following:
>>
>> <datasources>
>>   <no-tx-datasource>
>>     <jndi-name>boo</jndi-name>
>>
>>
>>
>>
>> <connection-url>jdbc:postgresql://localhost:5432/bar</connection-url>
>>   [ ... other attributes ... ] <new-connection-sql>SELECT
>> version()</new-connection-sql> <check-valid-connection-sql>SELECT
>> version()</check-valid-connection-sql> </no-tx-datasource>
>> </datasources>
>>
>> This validates the connection before it is handed out on the
>> application, and throws away invalid connections. Be aware that the
>> SQL is case sensitive, we had a problem with earlier versions of
>> OpenMDX/CRX that had upper case letters in the tags so they were
>> ignored by jboss.
>
> I'm using Resin, not JBoss. The above configuration means a lot of
> overhead, just to verify that a connection is still valid. Is this
> the recommended way in a production environment?
>
> I think this means that the PostgreSQL JDBC driver doesn't support
> automatic reconnection. And I don't see this feature on the Roadmap.
> Is it unusual to use PostgreSQL in a multi server environment?

Most JDBC drivers that I'm aware of don't do automatic reconnections.
We primarily use Oracle at work (sigh - I'm trying to change that -
long, slow effort) and it does not automatically reconnect.

I don't use Resin, but I just checked the Resin site here
http://www.caucho.com/resin-3.0/db/config.xtp#DataSource and it has the
same kind of connection validation that JBoss does.  See the section
titled "Reliability Configuration."  With that, Resin's DBPool will get
you a valid connection when they become available again.

>
> Without this feature I don't think PostgreSQL is the right choice for
> me and I keep using SAPDB. I could implement it in my server
> application, but within the servlet engine it is almost impossible to
> do outside the JDBC driver.

That does not appear to be the case.

--
Guy Rouillier


pgsql-jdbc by date:

Previous
From: "Markus Riehl"
Date:
Subject: Re: No automatic reconnect after network error
Next
From: Oliver Jowett
Date:
Subject: Re: No automatic reconnect after network error