Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Datasources connection pooling setups-whats the difference in these two approaches

Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I am using datasources[set up a datasource in Tomcat] like this:

<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
username="scott" password="tiger" maxActive="20" maxIdle="10"

and then using it with a factory class implementation like this:

public DataSource getDataSource() throws NamingException {

if (ds == null) {

InitialContext ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:comp/env");
ds = (DataSource) envCtx.lookup("jdbc/testDB");


return ds;

// get the SQL connection from the database
public Connection getConnection() throws NamingException, SQLException {
return getDataSource().getConnection();


Now I was reading about using oracle.jdbc.pool package and thereby setting up a datasource in tomcat like this:

<Resource name="jdbc/<alias>"
maxWait="-1" />

What is the difference between this implementation with the other implementation ? For our case[have30000 concurrent users which will be say 5000 concurrent DB hits] will it be beneficial to use the second approach ?

Can anyone give my some links for a Factory implementation using the second approach then ?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic