• 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

Refresh() method of oracleConnectionCacheManager!

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Thx!
***********************************************************


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();

try
{
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");
ex.printStackTrace();
}


try
{
ods = new OracleDataSource();
ods.setURL("jdbc racle:thin:@192.168.58.133:15111:locdb");
ods.setUser("codeCrackOpen");
ods.setPassword("codeCrackOpen");
ods.setLoginTimeout(0);
ods.setConnectionCachingEnabled(true);
ods.setConnectionCacheProperties(prop);
ods.setConnectionCacheName(cacheName);
occm.createCache(cacheName, ods, prop);

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

try
{
//repeatedly trigger following refreshInvalidConnectionInCache()
//10 sec interval
oraMon = new oraConnCacheMonitor();
oraMon.start();

} catch (Exception monExp) {
System.out.println("Exception when monExp");
monExp.printStackTrace();
}
} // 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!

Wilson
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

Thanks!
bear
Forum Bartender
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic