Forums Register Login

connection validation when db is down

+Pie Number of slices to send: Send
The scenario is like this.

A connection pool was configured with application server
Minimum number of connections > 0 were configured.
Hence they will be instantiated at server start up.
I used some of the connections and closed them except one.
Meanwhile DB went down.

The requirement is I want to check if this is a valid connection or not with out using a query (possibly with DUAL) and without using configurable options in application servers ( like TestonReserve).

What could be the simplest way without using the query to check the health of the connection as I need to make sure that it is healthier for next set of steps?

Also for the connection in the above scenario, if I cross check the same with null value, will it validate whether it is healthier or not?
also if I close the connection, will it somehow raise an exception as DB is down? or it will simply logically close the connection and release the same to connection pool irrespective whether DB is up or not?

Apprecaite your insights.

Regards
Hareesh
+Pie Number of slices to send: Send
 

What could be the simplest way without using the query to check the health of the connection

Why do you reject this functionality? It does exactly what you need.
Just take care that you use a cheap query that returns as least on row, and the pool will do what you want.

I wonder why you don't want to use this mechanism, and whet you suggest as a more appropriate approach for your application.
+Pie Number of slices to send: Send
 

he requirement is I want to check if this is a valid connection or not with out using a query (possibly with DUAL)



I have seen your requirement just now. you can off course use a query with dual. Its simple use this and see
SELECT SYSDATE FROM DUAL;
+Pie Number of slices to send: Send
Hi Jan/ Adeeb,

Thanks for the suggestions.
Just wondering about the performance point of view.

Also can con.setAutoCommit(con.getAutoCommit()) be used and catch the SQL exception to know if Connection is still valid or not?

Does the later one improves the efficiency in checking?

Regards
Hareesh
+Pie Number of slices to send: Send
 

Just wondering about the performance point of view.

Hi,
What performance requirements do you have? Does running the query "select 1 from dual" break this requirement?
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1350 times.
Similar Threads
connection validation and connection close method in connection pooling when DB is down
Connection Problem
Hibernate with Application server connection pool
How to open a connection pool to a database?
connection pooling
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:44:38.