Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application persistence across database shutdown/startup

 
Ninad Kuchekar
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an application and I am using a customized framework, which is similar to Struts + Hibernate. The problem I am facing is that, suppose an user is using the application and if the database shuts down, the user gets an error page saying "Runtime Error"(This page is already configured by my application ). Now I don't want the user to get this page in case the database is "up" and running again. In short, I want to refresh all the stale connections(from the Connection Pool) and let the user start afresh without any error page.

I am using Oracle 10g

FYI: I have already tried OracleConnectionCacheManager's refreshCache(cacheName, mode) method and it doesn't work, for me atleast.


The method I have used for getting a connection is below:
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your connection pool support validationQuery?
 
Ninad Kuchekar
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jan,

Thanks for your response. No I am not using any validation query. I thought it might hamper the performance a bit. Is it so? I am not completely aware of the consequences and also not sure how exactly does a validationQuery work .
What do you suggest? Any other options are also welcome.
Thanks again!
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to choose a very cheap query that returns at least one row, like "select 1 from dual".
This query is executed every time you ask a connection from the pool.
If the query does not return at least one row (that means: something is wrong) the pool discards the bad connection, and creates a brand new connection.

This mechanism is not very expensive, and helps you a lot.
No I am not using any validation query. I thought it might hamper the performance a bit.

My advise is: don't just assume that something is bad for performance.
 
Ninad Kuchekar
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Jan!!...
Could you help with using it? How do I configure it? I searched for "validationQuery" configuration, but found little help.
I am using JBoss 4

P.S.: Thanks for the advice too, I'll keep that in mind.
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from http://community.jboss.org/wiki/configdatasources



  • <check-valid-connection-sql> - an sql statement that is executed before it is checked out from the pool to make sure it is still valid. If the sql fails, the connection is closed and new ones created.
  •  
    Ninad Kuchekar
    Ranch Hand
    Posts: 64
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for nth time Jan...that one should resolve it.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic