Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2003

Tip: Looking for answers? Try searching our database.

testing for database availability

Thread view: 
GaryM - 27 Jun 2003 17:22 GMT
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 - 27 Jun 2003 18:09 GMT
> 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
Sys Admin - 28 Jun 2003 10:46 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.

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.