Subject Re: [Firebird-Java] Re: connection ??
Author Andrea Leopardo
Again I! do another consultation to you... I 've want to connect to a dataBase "Interbase" (version < 7,0) and I have JDK 1.2... this to driver FirebirdSQL-1.0,
serves to me?
again, thank in advance!
A.C. Andrea L. Leopardo
----- Original Message -----
Sent: Monday, July 14, 2003 6:59 PM
Subject: [Firebird-Java] Re: connection ??

> perhaps it is a quite idiot my doubt but... it would wish to know
> how I know that established a connection with the database.
> The query does not make it but in log, the variable "conn" (of the
> connection) contains a value, something as well as:
> org.firebirdsql.jdbc.Connection@7e3733, that means that established
> a connection ??

Yes, this message in the log means that a connection object was
created. However, this does not mean that connection is still valid.
Here's the example:

Connection con = DriverManager.getConnection(myURL, userName, password);
// If you did not get SQLException here, you have a fresh connection

System.out.println("Connection is " + con);
// now you will see something like
// Connection is org.firebirdsql.jdbc.FBConnection@12345

... // now you do something with connection

System.out.println("After close connection is " + con);
// now you will see something like
// After close connection is org.firebirdsql.jdbc.FBConnection@12345

However, if you try to use "con" connection object after con.close(),
you will get an excepion. So, if connection object is not null it does
not necessarily means that it is valid, it means that is _was_ valid
some time ago. However, if you call any of the method of this
connection object, you will get an exception.

There is no other way to check if connection is still established
except trying to execute a query that succeeds under any
circumstances. I use

SELECT CAST(1 AS INTEGER) test_col FROM rdb$database

You should get exactly one row with exactly one column called
"test_col" and its value must be 1.

And one more thing. Please, do not post in HTML, use plain text
message format.

Best regards,
Roman Rokytskyy

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Save up to 80% on top-quality inkjet cartridges & refill kits at
Free shipping on orders $50 or more to the US and Canada.

To unsubscribe from this group, send an email to:


Your use of Yahoo! Groups is subject to