Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Refresh() method of oracleConnectionCacheManager!

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

Posts: 67399
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
straws are for suckers. tiny ads are for attractive people.
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic