// construct pooling datasource
connectionPool = new GenericObjectPool(null, 0, GenericObjectPool.WHEN_EXHAUSTED_GROW, 0, 5);
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(dbUri, dbUser, dbPassword);
new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
DataSource dataSource = new PoolingDataSource(connectionPool);
// create JNDI context
rootContext = new InitialContext();
Context namingContext = lookupOrCreateNamingContext(rootContext, "java:comp");
namingContext = lookupOrCreateNamingContext(namingContext, "env");