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

connection pool with dbcp

 
vicky pribadhy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i have a problem while i'm using dbcp. i set 10 for maxActive. While my program is running, there are a lot connection instance created to oracle that inactive. so the oracle will lost connection resource.
can you give me some advice to avoid this problem

regards,

Vicky
 
Gaurav Arora
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some code would be most helpful.
 
vicky pribadhy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// method init will use to initialize properties

public static void init() throws Exception {

DriverAdapterCPDS myConnectionPoolDataSource = new DriverAdapterCPDS();
myConnectionPoolDataSource.setDriver("oracle.jdbc.driver.OracleDriver");

myConnectionPoolDataSource.setUrl("jdbcracle:thin:@localhost:1521:ORCL");

myConnectionPoolDataSource.setUser("userName");
myConnectionPoolDataSource.setPassword("userPassword");

sharedDataSource = new SharedPoolDataSource();

sharedDataSource.setConnectionPoolDataSource(myConnectionPoolDataSource);
sharedDataSource.setMaxActive(10);
sharedDataSource.setMaxWait(60);
sharedDataSource.setMaxIdle(10);
}


// method getConnection will use to get connection from pool

public static Connection getConnection() throws SQLException {
return sharedDataSource.getConnection();
}

regards,

Vicky
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic