Hi... 
 
This is what I have done in my application... I had specified the datasource in the 
struts config file...
 
<data-sources>
     <data-source>
       <set-property property="autoCommit" value="false"/>
       <set-property property="description" value="MySQL"/>
       <set-property property="driverClass" value="com.mysql.jdbc.Driver"/>
       <set-property property="maxCount" value="50"/>
       <set-property property="minCount" value="2"/>
       <set-property property="password" value="william"/>
       <set-property property="url" value="jdbc:mysql://localhost:3306/mysql"/>
       <set-property property="user" value="root"/>
     </data-source>
   </data-sources>
 
In between, I use this 'dataSource = servlet.findDataSource(null);' to get the 
datasource by running a singleton... In order for my beans to use connection, I try to 
write a common class that handles a pool of connections...
 
This is my connection pool class constructor, 
 
 private ConnectionPool() {
      // Create properties setting object
      this.waitIfBusy = true;
      this.initialConnections = 2;
      this.maxConnections = 50;
      if (initialConnections > maxConnections) {
         initialConnections = maxConnections;
      }
      availableConnections = new Vector(initialConnections);
      busyConnections = new Vector();
    
      for(int i=0; i<initialConnections; i++) {
         //try {
           availableConnections.addElement(makeNewConnection());
         //} catch (SQLException e) {
        //}
      }
   }

Now, if you look at it I have hard coded the max and min connection -- Is there any 
way whereby I can bring the mas and min values specified in struts-config file 
straight in here to this constructor... I am trying to make this into an utility...
 
Thanks in advance...
 
-Joseph

Navneet Karnani <[EMAIL PROTECTED]> wrote:
I think the connection manager that struts ships with has primitive 
connection pooling built into it. Just read the docs.

- Navneet

Joseph William said the following on 30/09/2003 4:17 AM:

> Hello...
> 
> I am developing a small application using Struts and am trying to connect with 
> MYSQL... I got it connected and even retrieved values by specifying the datasource 
> in the struts-config file...
> 
> Now, I am trying to put a common class for connection Pooling... I need to get the 
> values like the max, min connections that I had specified in the config file so that 
> I don't hard code values in my connection pooling utility... 
> 
> How do I access those values??? Is these any method I need to use coz this 
> connection pool class is a separate utility and does not extend Action...
> 
> Please let me know...
> 
> Thanks.
> -Joseph
> 
> 
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

Reply via email to