Have you tried using the max-pool-size setting on your datasource:

<min-pool-size>5</min-pool-size>
  |     <max-pool-size>100</max-pool-size>

By default, i guess the max-pool-size is 20(not sure though)
Here you will find the details:
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources

anonymous wrote : I get a new connection object when I call the init method of 
each of my servlets (there are about 20), that is the only connection object I 
use for that servlet (I pass it as a parameter to the various factory classes I 
use within the servlet to do database access). 

Is this really required to be done this way. Cant you create a new connection 
whenever you need it? If you are going by the approach you mention, then the 
Connection will be held by the servlet during its entire lifetime(i.e. until 
destroy() is called, where you can call Connection.close()). This would mean 
that the Connection will *NOT* be released till the servlet is destroyed. 
Ideally, you can lookup the datasource object in your init() method and 
maintain that datasource object through out the lifetime of the servlet. Then 
whenever an connection is required, use this datasource object and create a new 
connection.

Something like:

MyServlet.java:

init() {
  | 
  | DataSource ds   = null;
  |             String sourceName = "";
  |             
  |             try
  |             {
  |                     ctx = new InitialContext();
  |             
  |                     if(ctx == null )
  |                             throw new NamingException("Error 
'Db.getConnection' - No Context");
  |     
  |                     sourceName = this.getDbName(ctx);
  |                             
  |                     ds = (DataSource)ctx.lookup(sourceName);
  |             }
  |             catch (NamingException e)
  |             {
  |                     
MtrErr.writeExc(MtrErr.OTHER_SOURCE,this.getClass().toString(),"getConnection",e);
  |             }
  |             catch (Exception e)
  |             {
  |                     
MtrErr.writeExc(MtrErr.OTHER_SOURCE,this.getClass().toString(),"getConnection",e);
  |             }
  | 
  | 
  | }
  | 
  |  
  | doGet() {
  |  Connection conn = null;
  |  try {
  |   conn  = this.ds.getConnection();
  |  //use this connection object 
  | 
  |   } finally {
  |    //Dont forget to close the connection
  |    if (conn != null) {
  |     conn.close();
  |    }
  |  }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958034#3958034

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958034
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to