tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Burgess, Jay S" <>
Subject RE: Another Try at MySQL Connection Pooling
Date Wed, 11 Feb 2004 14:35:16 GMT
I too am not sure what the problem is, though I've got this working on
Windows at least.  Couple of comments:

First, what is the need for the second factory definition in the URL
i.e. socketFactory=com.mysql.jdbc.NamedPipeSocketFactory?  You've
already defined a factory in the <Resource> definition
(org.apache.commons.dbcp.BasicDataSourceFactory).  Maybe it's a Linux
requirement? On Windows, my URL simply looks like:

For working solution (at least on Windows), take a look a my post from
last week.  Maybe it'll shed some light.

Finally, as Josh requested, I've already sent him a ZIP containing a
very simple app that demonstrates this functionality in action.  He
indicated that he'd try to get it into an FAQ at some point.  If you're
interested, email me offline and I'd be happy to forward it to you as

Let us know how it progresses.


-----Original Message-----
From: David Smith [] 
Sent: Wednesday, February 11, 2004 8:03 AM
To: Tomcat Users List
Subject: Re: Another Try at MySQL Connection Pooling

I'm using this setup on a linux box and the only thing I can see 
different is your URL.  I'm not familiar with the named pipes method 
of accessing MySQL from Tomcat.  My URL is of this format:

jdbc:mysql://[server name]:3306/[database name]?autoReconnect=true

Also, did you place the mysql-connnector jar in the common/lib 
directory of the Tomcat directory?  It has to be there to use the 
DBCP connection pool.

Beyond those things, the error is most likely in your java code 
somehow.  Heaven knows I've beaten my head over enough simple errors 
and typos.


>I'm running
>   * Tomcat 5.0.18 running as a Wndows service,
>   * MySQL 4.0.16 running as a Windows service, and
>   * MySQL Connector/J 3.0.10 stable
>all on Windows 2000 Server, which is where I'm also doing the 
>testing (i.e., on localhost).
>A number of tomcat-user mailing list denizens have given me snippets 
>of XML to put in various places. Nothing worked.  So I tried 
>following the "MySQL Configuration" example from 
>After all changes were made to server.xml, web.xml and timesheet.xml 
>(the <context> fragment under conf/Catalina/localhost), I restarted 
>Tomcat and tried to login (the first action that would have had to 
>touch the MySQL database).
>I got the following errorPage:
>>  At Timesheet.Util.errorPage( there occurred a
>>  java.lang.Exception: A fatal exception occurred while retrieving 
>>login name and pass phrase because...
>>  At Timesheet.Util.getSqlConnection( there occurred a
>>  java.lang.Exception: Unable to establish a MysqlDataSource 
>>connection for ResourceLine name "jdbc/TimesheetsDB" >because...
>>  At org.apache.naming.NamingContext.lookup( 
>>there occurred a
>>  javax.naming.NameNotFoundException: Name jdbc is not bound in this
>OK, that seems to say it doesn't know what the name 
>"jdbc/TimesheetsDB" is.  Tomcat has written nothing to stderr.log 
>and stdout.log shows a clean startup, so Tomcat itself isn't too 
>perturbed.  stdout.log includes the following line:
>>  INFO: Processing Context configuration file URL file:C:\Program 
>>Files\Apache Group\Tomcat 
>implying that my timesheet.xml context fragment file was found and 
>processed.  The Timesheet application log file contains the 
>>  2004-02-10 16:20:05 
>>NamingContextListener[/Catalina/localhost/timesheet]:   Resource 
>>parameters for jdbc/TimesheetsDB = 
>>password=All41a14all, maxWait=10000, maxActive=100, 
>>, username=timesheet_app, 
>>  2004-02-10 16:20:05 
>>NamingContextListener[/Catalina/localhost/timesheet]:   Adding 
>>resource ref jdbc/TimesheetsDB
>>  2004-02-10 16:20:05 
>>  2004-02-10 16:20:05 
>>NamingContextListener[/Catalina/localhost/timesheet]:   Resource 
>>parameters for UserTransaction = null
>[Blank lines added for clarity.]  As per the instructions in the 
>jndi-datasource-examples-howto.html page, my web.xml file has the 
>following addition
>>   <resource-ref>
>  >     <description>MySql Connection Pool</description>
>>      <res-ref-name>jdbc/TimesheetsDB</res-ref-name>
>>      <res-type>javax.sql.DataSource</res-type>
>>      <res-auth>Container</res-auth>
>>   </resource-ref>
>immediately after the <error-page> element and immediately before 
>the <security-constraint> element.
>Now that I am using the timesheet.xml <context> fragment file, 
>server.xml is unchanged except that I have modified it to use port 
>80 in place of 8080 and port 443 in place of 8443.
>The timesheet.xml <context> fragment file looks like this:
><Context path="/timesheet" docBase="timesheet" debug="9"
>          crossContext="true" displayName="ConnectTel Timesheet
>   <Logger className="org.apache.catalina.logger.FileLogger"
>           prefix="localhost_timesheet_log." suffix=".txt"
>   <Resource name="jdbc/TimesheetsDB" auth="Container" 
>   <ResourceParams name="jdbc/TimesheetsDB">
>     <parameter>
>       <name>factory</name>
>       <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>     </parameter>
>     <parameter>
>       <name>maxActive</name> <!-- max db connections in the pool -->
>       <value>100</value>     <!-- 0 implies no limit -->
>     </parameter>
>     <parameter>
>       <name>maxIdle</name>   <!-- max idle db connections to retain 
>in pool --> 
>       <value>30</value>      <!-- 0 implies no limit -->
>     </parameter>
>     <parameter>
>       <name>maxWait</name>   <!-- max wait for connection before 
>throwing exception -->
>       <value>10000</value>   <!-- -1 implies no limit (time is in 
>milliseconds) -->
>     </parameter>
>     <parameter>
>      <name>username</name>
>      <value>timesheet_app</value>
>     </parameter>
>     <parameter>
>      <name>password</name>
>      <value>xxxxxxxxxxx</value>
>     </parameter>
>     <parameter>
>       <name>url</name>
>     </parameter> 
>     <parameter>
>        <name>driverClassName</name> <!-- Class name for mm.mysql 
>JDBC driver -->
>        <value></value>
>     </parameter>
>   </ResourceParams>
>I apologize for being so verbose, but I'm trying to provide all of 
>the relevant information in the initial message.  Does anyone see 
>what I've missed?  The example in 
>jndi-datasource-examples-howto.html does NOT look like the other 
>things I was told to do.  (?)
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message