pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Daniel Migowski <dmigowski@ikoffice.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Fastest way to check aliveness of connection
Date: Wed, 27 Feb 2008 11:20:24 +1300
Message-ID: <47C490A8.1090708@opencloud.com> (raw)
In-Reply-To: <47C415F8.2020406@ikoffice.de>
References: <47C415F8.2020406@ikoffice.de>

Daniel Migowski wrote:
> Hello,
> 
> I want to implement a c3p0 ConnectionTester and now need a fast way to 
> check for the alivelyness of a Connection. Currently I issue a "select 
> 1" to the database and if I don't get an exception I assume the 
> connection is still alive.
> 
> Is there a faster way? How can I check if the underlying socket is still 
> alive without doing a JDBC request? This has to work only with 
> PostgreSQL JDBC, so I can cast to any postgres interface available.

Running an empty query ("") is probably the simplest way.

In theory you could do something slightly faster at the protocol level 
(just send Sync and wait for ReadyForQuery) but there's no interface 
currently exposed to do that and I doubt that it will be much faster 
than an empty query anyway.

-O



view thread (3+ messages)  latest in thread

Message-ID: <47C490A8.1090708@opencloud.com>
Permalink:  ../47C490A8.1090708@opencloud.com/
Also on:    postgresql.org/message-id/47C490A8.1090708@opencloud.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: oliver@opencloud.com, dmigowski@ikoffice.de
  Subject: Re: Fastest way to check aliveness of connection
  In-Reply-To: <47C490A8.1090708@opencloud.com>
  References: <47C415F8.2020406@ikoffice.de> <47C490A8.1090708@opencloud.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