> What is the best way to test for the db server to be running? I have
> created a connection and am executing a simple statement.
The answer: Execute the simple statement. If it works, the DBMS is
running. If it fails, depending on what exception you get, the DBMS
may not be running.
In fact, there is no way for a client (including the driver) to know if
the connection to the server is good, except to try to use it. Furthermore,
as soon as the result comes back, we only know that the connection
*was* good. The very next use may fail. Thus your code will always
have to be able to handle the situation of a broken connection anywhere
in your code.
Joe Weinstein at BEA
> Thanks,
>
> Gary
I just fetch a little bit of the metadata, e.g. the DriverName or the
DB-Version.
As this needs a working connection to the DB, I know its fine.
Regards
Fredy
>What is the best way to test for the db server to be running? I have
>created a connection and am executing a simple statement.
>
>Thanks,
>
>Gary
Joseph Weinstein - 28 Jun 2003 16:31 GMT
> I just fetch a little bit of the metadata, e.g. the DriverName or the
> DB-Version.
> As this needs a working connection to the DB, I know its fine.
Beware that some metadata calls, such as DriverName are usually
hardwired into the driver itself (no dbms contact needed), and
others, like the db version may need dbms contact once per connection,
and the driver may cache the answer and avoid the dbms roundtrip
after that. The most reliable is one that make the DBMS do a minimm
of parsing but does ask the DBMS something where the answer could
be different each time you ask.
> Regards
>
[quoted text clipped - 6 lines]
> >
> >Gary
Mark Benson - 28 Jun 2003 17:04 GMT
Fredy,
Meta data sometimes gets cached by the driver. The best way is to issue
a simple select statement like:
select 'Test' from AnySmallTable where 1 = 0
MB
> I just fetch a little bit of the metadata, e.g. the DriverName or the
> DB-Version.
[quoted text clipped - 9 lines]
>>
>> Gary