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 / December 2006

Tip: Looking for answers? Try searching our database.

JDBC Connection returns wrong status

Thread view: 
evgchech - 15 Dec 2006 14:07 GMT
Hello Everybody

I am using jdbc:odbc driver to connect to MSSQL 2000
I acquire the connection object using DriverManager.getConnection()
I observe some strange behavior of the connection object.
If the database was brought down , the connection keeps returning false
on
m_conConnection.isClosed() query same goes for
m_conConnection.getMetaData().
I have clanged the driver to the Microsoft native one
jdbc:microsoft:sqlserver, and still the same behavior.
How do i know whether the connection is active or not??

Please help
joeNOSPAM@BEA.com - 15 Dec 2006 16:15 GMT
Connection.isClosed(0 is a pretty useless method. By spec, all it means
is whether *you* closed the connection. There is no way to know a
connection
is still good except to try and use it. Even if there was an
isThisConnectionGood()
method, the DBMS could go down right after you called it, so you have
to code
in a way that handles filed connections at any time, as best you
can....
GetMetaData() just returns you an object. You'd have to make an actual
metadata call, and one that requires talking to the DBMS, to see if the
connection
was good. ANd even if you do something like getting the database
version,
the driver may have already cached that from when it first logged in.
Do a "select 1" if you want to test...

Joe Weinstein at BEA Systems
Robert Klemme - 18 Dec 2006 14:19 GMT
Adding to Joe's comment: the ODBC JDBC bridge is not one of the best
drivers around.  I suggest you use one of the native drivers (the one
provided by MS or jTDS).  You are a lot less likely to run into troubles
with those plus they'll work on *all* platforms and have no added
dependencies (unless you want to use NTLM).

Kind regards

    robert


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.