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 / February 2004

Tip: Looking for answers? Try searching our database.

Connection reset on MS JDBC driver

Thread view: 
Andy Fish - 12 Feb 2004 14:36 GMT
Hi,

I have a problem with the MS JDBC driver whereby when I try to use a
connection after a long time idle it reports:

[Microsoft][SQLServer 2000 Driver for JDBC]Connection reset by peer

I've read plenty discussion on the subject and am convinced that
rather than trying to stop sockets from ever being closed, I need to
detect and re-open the connection.

I can't afford to rejig all the database code to detect this exception
and retry so I want to have my home made connection pool test the
connection before giving it out.

My question is, is there a way of pinging the server through JDBC to
see if the physical connection is still alive? If I have to do a SQL
command, what would be a good example of something that is guaranteed
to get through to the server but not take up too much processing or
network?

it seems to be accepted that any good connection pool should have this
feature - so if anyone knows how they do it I would like to know.

many thanks for any suggestions

Andy
Silvio Bierman - 12 Feb 2004 18:47 GMT
> Hi,
>
[quoted text clipped - 23 lines]
>
> Andy

That is possible but can be quite expensive. Why not keep a last-used
timestamp with the connections in the pool and refresh connections when they
are about to be taken from the pool and are older than some treshold. This
approach works great in our long-running server applications.

Silvio Bierman
Andy Fish - 12 Feb 2004 19:19 GMT
> > Hi,
> >
[quoted text clipped - 30 lines]
>
> Silvio Bierman

Thanks, I think I will use this approach.

FWIW I am doing a 'select @@spid' command to test if the server is still
there

Andy
Silvio Bierman - 12 Feb 2004 22:11 GMT
> > > Hi,
> > >
[quoted text clipped - 38 lines]
>
> Andy

The query may be light, it still takes a full roundtrip which, when taking
network latency into account, can be quite noticeable, especially when using
small bandwidths.

Silvio Bierman
Andy Fish - 13 Feb 2004 11:14 GMT
<snip>

> The query may be light, it still takes a full roundtrip which, when taking
> network latency into account, can be quite noticeable, especially when using
> small bandwidths.
>
> Silvio Bierman

indeed, but the purpose of the original post was to ascertain whether there
is any "lighter" way to test if the connection is still alive (and I beleive
the conclusion is that there is not)

therefore I will use the combination of the lightest query I can think of,
combined with the timeout period so I only test the connection if it has
been idle for a while


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.