Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar


Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any body tell me how to create connection pools in WAS 3.5 and use them in EJB, JSP etc
Thanx :-)
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Weel, I hope this helps you
To create a datasource on demand in an application, the application must do the following:

1. Create a Properties object with datasource properties.

2. Obtain a datasource from the factory.

3. Bind the datasource into JNDI.


try {

//Create a properties file for the DataSource java.util.Properties prop = new java.util.Properties();



prop.put(DataSourceFactory.DESCRIPTION,"My sample

prop.put("databaseName", "sample");

//Obtain a DataSource from the factory
DataSource ds = DataSourceFactory.getDataSource(prop);

//Bind the DataSource into JNDI

} catch (ClassNotFoundException cnfe){

//check the class path for all necessary classes

} catch (CMFactoryException cmfe){

//Example of exception: incorrect


} catch (NamingException ne) {

//Example of exception:

//datasource by this name may already exist


I am working with WebSphere 4.0 and I am also using the pool, we could stay in contact to help each other.
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do we actually get the database connection after that ?

I'm using the following class for getting connection ,

class DBConnect {
static DataSource ds = null;
static {
try {
Hashtable parms = new Hashtable();
Context ctx = new InitialContext(parms);
ds = (DataSource) ctx.lookup("jdbc/jndi");
}catch(Exception e) {
public Connection getDBConnection(){
Connection conn = null;
try {
conn = ds.getConnection("USER","PASSWD");
}catch(Exception e) {
and calling getconnection whenever I need a connection. Will this not maintain a connection pool. In the help page Websphere states that getting connection thorugh DataSource will automatically maintain a connection Pool.
please include me in your loop
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!