Lists: | pgsql-jdbc |
---|
From: | Daniel Migowski <dmigowski(at)ikoffice(dot)de> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Fastest way to check aliveness of connection |
Date: | 2008-02-26 13:36:56 |
Message-ID: | 47C415F8.2020406@ikoffice.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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.
With best regards,
Daniel Migowski
From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | Daniel Migowski <dmigowski(at)ikoffice(dot)de> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Fastest way to check aliveness of connection |
Date: | 2008-02-26 22:20:24 |
Message-ID: | 47C490A8.1090708@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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
From: | Daniel Migowski <dmigowski(at)ikoffice(dot)de> |
---|---|
To: | Oliver Jowett <oliver(at)opencloud(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Fastest way to check aliveness of connection |
Date: | 2008-02-27 07:57:13 |
Message-ID: | 47C517D9.9020405@ikoffice.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Hello Oliver,
Oliver Jowett schrieb:
> 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.
Yes, I investigated that, but since the normal query procedure also just
sends one package, the gain for just sending the sync does not really
matter. Of course, your idea with the empty query is great. Thanks alot.
With best regards,
Daniel Migowski