You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Chris Allen <to...@yahoo.com> on 2003/03/05 20:18:16 UTC

DBCP: Config in Struts

All,

I am having trouble utilizing DBCP in Struts 1.0.2.

My datasource tag in struts-config.xml looks something
like this:

------------

<data-source key="conPool"
type="org.apache.commons.dbcp.BasicDataSource">
    <set-property
      property="driverClassName"
      value="oracle.jdbc.driver.OracleDriver" />
    <set-property
      property="url"
      value="jdbc:oracle:thin:@{mydomain
here}:1521:{my sid here}" />
    <set-property
      property="username"
      value="xxxxxxx" />
    <set-property
      property="password"
      value="xxxxxxx" />
    <set-property
      property="maxActive"
      value="25" />
    <set-property
      property="maxIdol"
      value="6" />
    <set-property
      property="maxWait"
      value="-1" />
    <set-property
      property="removeAbandoned"
      value="true" />
    <set-property
      property="removeAbandonedTimeout"
      value="60" />
    <set-property
      property="defaultAutoCommit"
      value="false" />
    <set-property
      property="defaultReadOnly"
      value="false" />
    <set-property
      property="validationQuery"
      value="select SYSDATE from dual" />

</data-source>

---------------

I access the datasource by doing the following:

+++++++++++++++

// all of my actions have this equivalent
    DataSource ds = servlet.findDataSource("conPool");

    try {
        con = ds.getConnection();
        LogonDAO logonDAO = new LogonDAO(con);
        // the DAO object use the con for
PreparedStatements
        user = logonDAO.logon(pUser);
    }
    catch(Exception e) {
        throw e;
    }
    finally {
        try {
            con.close()
        }
        catch(SQLException sqle) {
            throw sqle;
        }
    }

+++++++++++++++

When I loadtest with JMeter, and assign 3 Virtual
Users, it will open no more than 1 db connection per
user (3 conns).  Needless to say, its slow, and their
doesn't seem to be much pooling going on.

It must be a config issue.  Where is a standard
dbcp/struts example?

Thanks in advance,

Chris


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

Re: DBCP: Config in Struts

Posted by Rodney Waldhoff <rw...@apache.org>.
I'm not sure this explains your problem, but the property "maxIdol" should
probably be "maxIdle".

On Wed, 5 Mar 2003, Chris Allen wrote:

> All,
>
> I am having trouble utilizing DBCP in Struts 1.0.2.
>
> My datasource tag in struts-config.xml looks something
> like this:
>
> ------------
>
> <data-source key="conPool"
> type="org.apache.commons.dbcp.BasicDataSource">
>     <set-property
>       property="driverClassName"
>       value="oracle.jdbc.driver.OracleDriver" />
>     <set-property
>       property="url"
>       value="jdbc:oracle:thin:@{mydomain
> here}:1521:{my sid here}" />
>     <set-property
>       property="username"
>       value="xxxxxxx" />
>     <set-property
>       property="password"
>       value="xxxxxxx" />
>     <set-property
>       property="maxActive"
>       value="25" />
>     <set-property
>       property="maxIdol"
>       value="6" />
>     <set-property
>       property="maxWait"
>       value="-1" />
>     <set-property
>       property="removeAbandoned"
>       value="true" />
>     <set-property
>       property="removeAbandonedTimeout"
>       value="60" />
>     <set-property
>       property="defaultAutoCommit"
>       value="false" />
>     <set-property
>       property="defaultReadOnly"
>       value="false" />
>     <set-property
>       property="validationQuery"
>       value="select SYSDATE from dual" />
>
> </data-source>
>
> ---------------
>
> I access the datasource by doing the following:
>
> +++++++++++++++
>
> // all of my actions have this equivalent
>     DataSource ds = servlet.findDataSource("conPool");
>
>     try {
>         con = ds.getConnection();
>         LogonDAO logonDAO = new LogonDAO(con);
>         // the DAO object use the con for
> PreparedStatements
>         user = logonDAO.logon(pUser);
>     }
>     catch(Exception e) {
>         throw e;
>     }
>     finally {
>         try {
>             con.close()
>         }
>         catch(SQLException sqle) {
>             throw sqle;
>         }
>     }
>
> +++++++++++++++
>
> When I loadtest with JMeter, and assign 3 Virtual
> Users, it will open no more than 1 db connection per
> user (3 conns).  Needless to say, its slow, and their
> doesn't seem to be much pooling going on.
>
> It must be a config issue.  Where is a standard
> dbcp/struts example?
>
> Thanks in advance,
>
> Chris
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>