jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Refresh() method of oracleConnectionCacheManager! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Refresh() method of oracleConnectionCacheManager!" Watch "Refresh() method of oracleConnectionCacheManager!" New topic

Refresh() method of oracleConnectionCacheManager!

Wilson Tsing Yi

Joined: Jul 12, 2004
Posts: 2
Dear Expert,

I feel painful when testing with the Refresh() method of oracleConnectionCacheManager. Pls help.

I am using oracle 10g JDBC Driver and conect to oracle 8.1.7 DB Server

I use 10g for detecting and replacing failed cached connection. But I have a big problem in my testing. PLs help. The number of connections (all are ESTABLISHED view at netstat) grows when calling
oracleDataSource's getConnection() method after calling to oracleConnectionCacheManager's refresh() method. Lastly, exception throws when it reached max. connection setting. In fact, the connection is oracle server is good and the cached connections are good also.

I expect that the refresh() method should find all connections are good and no connection replacement in my test. Incoming connection requests served from the original cached connections. However, My test found that every calling to refresh() will cause old connection or oracleDataSource can't be reused for next getConnection() equest. But old connections are still maintained in ESTABLISHED state. Hence, size of connection grows continuously if refresh() and getConnection() repeatedly. PLs help me , so that original cached connections can be used after tirggering refresh() method.

My Goal : my application can detect and replace the fail cached connections, so that my application can work normally without stopping and automatically reconect to DB , even DB server/network down and then resume.

(My Guess) Every time triggering to refresh() methods will created a new oracleDataSource object, from which new connection requests are served. However, the old connection in old oracleDataSource object still maintained. But can't be used.

Pls correct me if any mistake made in my understanding .
Welcome suggestion. Further information. welcome let me know.

public class oraConnCacheManager {

static OracleConnectionCacheManager occm = null;
static java.util.Properties prop = new java.util.Properties ();
static OracleDataSource ods= null;
static String cacheName = "oraConnTest";

//oraMon is a thread for triggering refresh() repeatedly
static oraConnCacheMonitor oraMon=null;

public oraConnCacheManager()
throws dbException , SQLException
occm = OracleConnectionCacheManager.getConnectionCacheManagerInstance();

prop.setProperty("InitialLimit", "0");
prop.setProperty("MinLimit", "1" );
prop.setProperty("MaxLimit", "3");
prop.setProperty("MaxStatementsLimit", "10");
prop.setProperty("InactivityTimeout", "0");
prop.setProperty("AbandonedConnectionTimeout", "900");
prop.setProperty("PropertyCheckInterval", "60");
prop.setProperty("ValidateConnection", "true");
prop.setProperty("TimeToLiveTimeout", "0");
prop.setProperty("ConnectionWaitTimeout", "5");

} catch (Exception ex) {
System.out.println("Exception when creating Exception");

ods = new OracleDataSource();
ods.setURL("jdbc racle:thin:@");
occm.createCache(cacheName, ods, prop);

} catch (Exception odsExp) {
System.out.println("Exception when setting oracleDataSource");

//repeatedly trigger following refreshInvalidConnectionInCache()
//10 sec interval
oraMon = new oraConnCacheMonitor();

} catch (Exception monExp) {
System.out.println("Exception when monExp");
} // end of oraConnCacheManager constructor

public static void refreshInvalidConnectionInCache()
throws Exception
occm.refreshCache(cacheName , OracleConnectionCacheManager.REFRESH_INVALID_CONNECTIONS);
occm.reinitializeCache(cacheName, prop);

public static void refreshAllConnectionInCache()
throws Exception
occm.refreshCache(cacheName , OracleConnectionCacheManager.REFRESH_ALL_CONNECTIONS);
occm.reinitializeCache(cacheName, prop);

public synchronized Connection getConnection()
throws dbException , SQLException
return ods.getConnection();

} // end of oraConnCacheManager

Best Regards & Thx!

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63837

"Mr Wilson",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Refresh() method of oracleConnectionCacheManager!
It's not a secret anymore!