Subject Re: connection ??
Author Roman Rokytskyy
> 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