You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joseph William <st...@yahoo.com> on 2003/09/30 00:47:54 UTC
Connection Pooling...
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
Re: Connection Pooling...
Posted by Joseph William <st...@yahoo.com>.
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 <na...@myrealbox.com> 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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
Re: Connection Pooling...
Posted by Navneet Karnani <na...@myrealbox.com>.
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Connection Pooling...
Posted by Kwok Peng Tuck <pe...@makmal.net>.
Tomcat provides a connection pool for you via a JNDI datasource, so you
need to rely on the struts datasource.
You can find out a little more over here :
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
Joseph William wrote:
>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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org