• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

connection validation when db is down

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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;
 
Hareesh Ram Chanchali
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jan Cumps
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
reply
    Bookmark Topic Watch Topic
  • New Topic