pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Schaber <schabi@logix-tt.com>
To: Markus Riehl <mriehl@skat.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: No automatic reconnect after network error
Date: Mon, 10 Apr 2006 17:53:30 +0200
Message-ID: <443A7F7A.6090509@logix-tt.com> (raw)
In-Reply-To: <003301c65cb1$038f0830$15b2a8c0@pcmar02>
References: <003301c65cb1$038f0830$15b2a8c0@pcmar02>

Hi, Markus,

Markus Riehl wrote:

> Using MySQL or SAPDB, the JDBC driver is automatically reconnecting to the
> database when the connection is up again. Is there a way to use the PSQL
> driver the same way?

Currently, the backend cannot keep the current transaction if the
connection breaks, so it will be rolled back.

> How is this problem handled within Connection Pools (used within a servlet
> environment)? Is the pool deleting "dead" connections automatically and is
> creating new ones?

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.

HTH,
Markus
-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org



view thread (5+ messages)  latest in thread

Message-ID: <443A7F7A.6090509@logix-tt.com>
Permalink:  ../443A7F7A.6090509@logix-tt.com/
Also on:    postgresql.org/message-id/443A7F7A.6090509@logix-tt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: schabi@logix-tt.com, mriehl@skat.com
  Subject: Re: No automatic reconnect after network error
  In-Reply-To: <443A7F7A.6090509@logix-tt.com>
  References: <003301c65cb1$038f0830$15b2a8c0@pcmar02> <443A7F7A.6090509@logix-tt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox