|
Home > Archive > PostgreSQL JDBC > December 2005 > an efficient way of checking if the connection to a db is actually open
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
an efficient way of checking if the connection to a db is actually open
|
|
| Assad Jarrahian 2005-12-15, 8:25 pm |
| Hi All,
Trying to check if a connection is actually open every time I perform an
operation (if not, I want to reopen it and perform that operation).
isClosed()
*<[url]http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection. html#isClosed%28%29[
/url]>
* is no good, as in, it only guarantees true if close() was actually called
on it.
The documentation says, the only real way is to actually call an sql
statement on it. That seems inefficient. Is there any other way that is
recommended?
Much thanks in advance.
-assad
| |
| Paul Thomas 2005-12-15, 8:25 pm |
|
On 15/12/2005 20:47 Assad Jarrahian wrote:
> The documentation says, the only real way is to actually call an sql
> statement on it. That seems inefficient. Is there any other way that is
> recommended?
Something like SELECT now() would be quick as doesn't involve any database
access.
--
Paul Thomas
+------------------------------+-------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for Business |
| Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+-------------------------------------------+
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
| |
| Guillaume Cottenceau 2005-12-16, 3:24 am |
| Assad Jarrahian <jarraa 'at' gmail.com> writes:
> Hi All,
> Trying to check if a connection is actually open every time I perform an
> operation (if not, I want to reopen it and perform that operation).
Why not performing the operation anyway, and when it fails
reopening the connection and retrying the operation?
Seems that it's the idea the JDBC designers had in mind, which
doesn't seem too stupid.
--
Guillaume Cottenceau
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly
|
|
|
|
|