Hi I am using connection pooling in struts and it works fine also. But if there is connection failure in network how can we find that the there is no connections in connection pool or how can we test the connection is live or not without producing exception. Because in such conditions when i use
then it produces exceptions. Anybody have idea please inform me.
Would a validation query help you? If you provide one, your connection pool will first try to execute that query. If this query fails, the pool discards the bad connection, and gets a fresh connection for you.
(assuming you are using the Apache connection pool)
I think the dbcp class will try execute that query when a getConnection()called, so that might produce the exception
Yes, it tries to execute it. But it should not throw an exception when it tries to hand you a bad connection. In stead, it tries to fix the connection. Maybe your database is not reachable when you try to get your connection. In that case, your connection pool won't be able to get a fresh connection for you.
Why don't you show us your exception?
Joined: Sep 22, 2008
Thanks for your reply
When there is network failure i got exception. What i want is if the dbcp can't create connection pool then it should return null value or something instead of just throwing exception.
Why i don't show stacktrace is that i know why the error occurs, it because of n/w failure only(ie purposly i disable the n/w connection). Why i am doing this means, this web application is going to deployed in client place. Before that i should know what are all the exceptions possible and tried to solve it that is other than getting exception. There is no way i think other than catching exceptions and handling the failure.