You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Kenneth B. Harwood" <ru...@comcast.net> on 2005/07/21 22:53:20 UTC

Re: DBCP datasource works on 5.0.28 but fails on 5.5.

This issue was originally submitted by Steve Kirk on 20-May-2005
and RESOLVED on 22-May.  FYI, I experienced the same error(s) as 
Steve and tried all the same things Steve did before discovering 
Steve's question (and thread) on the User List.  The fix (as first
advised by Lutz & Nicola) was to create the configuration files with
the proper settings.  I'm running:

Apache 2.0.54 (w/the latest mod_jk)
TC 5.5.9 (w/multiple instances)
mySQL Server 4.1
Win2K Pro (w/multiple IP addresses)

The thread was very helpful.  I solved my problem after QUADRUPLE
CHECKING my <web.xml> and <context.xml> files.  I don't know what
exactly fixed it, but this is what I did (and currently have):

<WEB.XML>
1) Remove the <resource-ref> related to my database connection 

<CONTEXT.XML>
1) Use the "improved" Resource element style.  
That is, define as many params as possible within the Resouce Tag:

   <Resource name="jdbc/mysqlTestDb" auth="Container" type="javax.sql.DataSource"/>

2) Define additional non/essential parameters within the <ResourceParams> Tag:

   <ResourceParams name="jdbc/mysqlTestDb">
        <parameter>
            <name>factory</name>
            <value>org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory</value>
        </parameter>
        <parameter>
             <name>testWhileIdle</name>
             <value>true</value>
        </parameter>
        <parameter>
             <name>timeBetweenEvictionRunsMillis</name>
             <value>10000</value>
        </parameter>
        <parameter>
             <name>minEvictableIdleTimeMillis</name>
              <value>60000</value>
        </parameter>
   </ResourceParams>

3) Note possible incorrect documentation

Note I am using org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.

According to the TC docs, the "factory" setting should be:
org.apache.commons.dbcp.BasicDataSourceFactory

There was another thread on this userlist (I can't locate it now) which 
advised using a different class. All I can say is that when I extract the 
class list from /Tomcat/common/lib/naming-factory-dbcp.jar,
I do *not* see org.apache.commons.dbcp.BasicDataSourceFactory.

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

Now my SQL statement (w/TagLib) works just fine:

  ...
<c:catch var="err1">
      <sql:update sql="INSERT INTO mytable VALUES (?)"
                      dataSource="jdbc/mysqlTestDb" var="ok">
            <sql:param value="${p1}"/>
      </sql:update>
</c:catch>

 - Ken H.

RE: DBCP datasource works on 5.0.28 but fails on 5.5.

Posted by Warren Taylor <ww...@sunbeltbusinessbrokersofms.com>.
Please stop sending this stuff to me.  Somehow, by mistake, I got on this
mailing list and don't know a thing about it.

WARREN TAYLOR
Sunbelt Business Advisors
Sunbelt Business Brokers of MS
www.sunbeltnetwork.com

-----Original Message-----
From: Kenneth B. Harwood [mailto:run10kswim@comcast.net] 
Sent: Thursday, July 21, 2005 3:53 PM
To: Tomcat Users List
Subject: Re: DBCP datasource works on 5.0.28 but fails on 5.5.

This issue was originally submitted by Steve Kirk on 20-May-2005
and RESOLVED on 22-May.  FYI, I experienced the same error(s) as 
Steve and tried all the same things Steve did before discovering 
Steve's question (and thread) on the User List.  The fix (as first
advised by Lutz & Nicola) was to create the configuration files with
the proper settings.  I'm running:

Apache 2.0.54 (w/the latest mod_jk)
TC 5.5.9 (w/multiple instances)
mySQL Server 4.1
Win2K Pro (w/multiple IP addresses)

The thread was very helpful.  I solved my problem after QUADRUPLE
CHECKING my <web.xml> and <context.xml> files.  I don't know what
exactly fixed it, but this is what I did (and currently have):

<WEB.XML>
1) Remove the <resource-ref> related to my database connection 

<CONTEXT.XML>
1) Use the "improved" Resource element style.  
That is, define as many params as possible within the Resouce Tag:

   <Resource name="jdbc/mysqlTestDb" auth="Container"
type="javax.sql.DataSource"/>

2) Define additional non/essential parameters within the <ResourceParams>
Tag:

   <ResourceParams name="jdbc/mysqlTestDb">
        <parameter>
            <name>factory</name>
 
<value>org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory</value>
        </parameter>
        <parameter>
             <name>testWhileIdle</name>
             <value>true</value>
        </parameter>
        <parameter>
             <name>timeBetweenEvictionRunsMillis</name>
             <value>10000</value>
        </parameter>
        <parameter>
             <name>minEvictableIdleTimeMillis</name>
              <value>60000</value>
        </parameter>
   </ResourceParams>

3) Note possible incorrect documentation

Note I am using org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.

According to the TC docs, the "factory" setting should be:
org.apache.commons.dbcp.BasicDataSourceFactory

There was another thread on this userlist (I can't locate it now) which 
advised using a different class. All I can say is that when I extract the 
class list from /Tomcat/common/lib/naming-factory-dbcp.jar,
I do *not* see org.apache.commons.dbcp.BasicDataSourceFactory.

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

Now my SQL statement (w/TagLib) works just fine:

  ...
<c:catch var="err1">
      <sql:update sql="INSERT INTO mytable VALUES (?)"
                      dataSource="jdbc/mysqlTestDb" var="ok">
            <sql:param value="${p1}"/>
      </sql:update>
</c:catch>

 - Ken H.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org