|
-
Connection isClosed.
What is the best way to know if a connection, is still alive or not.
The method isClosed seems to be irreliable.
-
Re: Connection isClosed.
Hello Arunkmar,
the isClosed() method returns whether a specified Connection has been closed
or not. Possibly, as you mention, individual implementations might not identify
a "corrupt" connection (one that has for some reason lost its physical database
connection) as being "closed". Therefore, to ensure that a connection is
valid, you might want to implement a method that actually validates a connection,
by having it perform a simple task, such as creating a Statement.
Obviously, this process might incur overhead if performed each time a connection
is used. If you are using connection pooling (which I assume you are), a
good way is to let the connection pool manage a monitor thread, that regularly
checks on the connections in the pool, and discards corrupt connection (closes
them, that is).
Let me know if this did any help!
Cheers,
Bjarki
"Arunkumar" <arunc@aztec.soft.net> wrote:
>
>What is the best way to know if a connection, is still alive or not.
>The method isClosed seems to be irreliable.
>
-
Re: Connection isClosed.
Hi Bjarki,
Thanks for ur reply.
What we have done is, we are trying to execute a select count(*) from A_DUMMY_TABLE
(with no rows) and if this fails, then we are resetting the
connection.
Think this will have minimal performance issues.
Any comments.
Thanks
Arunkumar
"Bjarki Holm" <holm@vyre.com> wrote:
>
>Hello Arunkmar,
>
>the isClosed() method returns whether a specified Connection has been closed
>or not. Possibly, as you mention, individual implementations might not identify
>a "corrupt" connection (one that has for some reason lost its physical database
>connection) as being "closed". Therefore, to ensure that a connection is
>valid, you might want to implement a method that actually validates a connection,
>by having it perform a simple task, such as creating a Statement.
>
>Obviously, this process might incur overhead if performed each time a connection
>is used. If you are using connection pooling (which I assume you are), a
>good way is to let the connection pool manage a monitor thread, that regularly
>checks on the connections in the pool, and discards corrupt connection (closes
>them, that is).
>
>Let me know if this did any help!
>
>Cheers,
>
>Bjarki
>
>"Arunkumar" <arunc@aztec.soft.net> wrote:
>>
>>What is the best way to know if a connection, is still alive or not.
>>The method isClosed seems to be irreliable.
>>
>
-
Re: Connection isClosed.
Arunkmar,
it should be enough to test whether the connection can produce a Statement
object. This might incur overhead, if done each time a connection is used,
although that will always depend on the type of system you are developing.
In a Web scenario, for example, I would not recommend this for each connection
that is used, but in a more simple scenario, where the number of concurrent
users is more limited, that might be acceptable.
- Bjarki
Similar Threads
-
By Daniel Teufert in forum VB Classic
Replies: 2
Last Post: 04-24-2002, 02:34 PM
-
By Will Rickards in forum Database
Replies: 1
Last Post: 04-06-2001, 03:50 PM
-
By Adam Dawes in forum VB Classic
Replies: 3
Last Post: 12-21-2000, 11:50 AM
-
By Darta in forum VB Classic
Replies: 1
Last Post: 10-24-2000, 04:48 PM
-
By markos in forum VB Classic
Replies: 0
Last Post: 04-03-2000, 12:20 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks