OracleConnectionCacheManager - Event Listener

Hi,

I have an Oracle 10g database and we are developping a 3-tier application. I am currently working on the database connection management (Connection Pooling) and would like to notify client applications when there is a problem with connecting to the database and then notify when connection is available again later.

At first, I used OracleDataSource and OraclePooledConnection, but now it seems that OracleConnectionCacheManager is much more useful and "powerful". Now that this is implemented, how can I add an event listener to the caching object so that when physical connection to DB goes down, my app could send a notification?

Thanks
whiteeaglAsked:
Who is Participating?
 
mariecConnect With a Mentor Commented:
try with the ValidateConnection property on the Connection Cache:


OracleDataSource ods = new OracleDataSource();
ods.setURL(url);
ods.setUser(user);
ods.setPassword(pwd);
       
//Enable caching
ods.setConnectionCachingEnabled(true);
//Set the cache name
ods.setConnectionCacheName(CACHE_NAME);
       
PropertsProperties = new java.util.Properties();
sProperties.setProperty("MinLimit", "1");
sProperties.setProperty("MaxLimit", "20");
sProperties.setProperty("ValidateConnection", "true"); // Validates connection before sending to client
       
ods.setConnectionCacheProperties(sProperties);
OracleConnectionCacheManager sConnectionCacheMananger = OracleConnectionCacheManager.getConnectionCacheManagerInstance();
sConnectionCacheMananger.createCache(CACHE_NAME, ods, sProperties);
0
 
whiteeaglAuthor Commented:
Is there any good/better way to check if the connection still is working?
0
 
whiteeaglAuthor Commented:
I'm still looking for a good solution concerning this connection validation problem.

Is there somthing like validationQuery for OracleDataSource or ConnectionCacheManager ?

I know that I could simply query the DB every time the users need a connection, but I guess it is just a workaround...
0
 
whiteeaglAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.