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:
jdbc:microsoft:sqlserver://MY_SERVER:1433;Database=MY_DATABSE

For working solution (at least on Windows), take a look a my post from
last week.  Maybe it'll shed some light.
 
http://marc.theaimsgroup.com/?l=tomcat-user&m=107608296706322&w=2

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
well.

Let us know how it progresses.

Jay

-----Original Message-----
From: David Smith [mailto:[EMAIL PROTECTED] 
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.

--David

>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 
>http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-example
s-howto.html. 
>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(Util.java:550) there occurred a
>>  java.lang.Exception: A fatal exception occurred while retrieving 
>>login name and pass phrase because...
>>
>>  At Timesheet.Util.getSqlConnection(Util.java:492) there occurred a
>>  java.lang.Exception: Unable to establish a MysqlDataSource 
>>connection for ResourceLine name "jdbc/TimesheetsDB" >because...
>>
>>  At org.apache.naming.NamingContext.lookup(NamingContext.java:814) 
>>there occurred a
>>  javax.naming.NameNotFoundException: Name jdbc is not bound in this
Context
>
>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 
>>5.0.18\conf\Catalina\localhost\timesheet.xml
>
>implying that my timesheet.xml context fragment file was found and 
>processed.  The Timesheet application log file contains the 
>following:
>
>>  2004-02-10 16:20:05 
>>NamingContextListener[/Catalina/localhost/timesheet]:   Resource 
>>parameters for jdbc/TimesheetsDB = 
>>ResourceParams[name=jdbc/TimesheetsDB, 
>>parameters={factory=org.apache.commons.dbcp.BasicDataSourceFactory, 
>>url=jdbc:mysql://localhost/Timesheets?autoReconnect=true&socketFactory
=com.mysql.jdbc.NamedPipeSocketFactory, 
>>password=All41a14all, maxWait=10000, maxActive=100, 
>>driverClassName=org.gjt.mm.mysql.Driver, username=timesheet_app, 
>>maxIdle=30}]
>
>>  2004-02-10 16:20:05 
>>NamingContextListener[/Catalina/localhost/timesheet]:   Adding 
>>resource ref jdbc/TimesheetsDB
>
>>  2004-02-10 16:20:05 
>>NamingContextListener[/Catalina/localhost/timesheet]: 
>>ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,f
actoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,co
ntent=Shareable},{type=auth,content=Container},{type=factory,content=org
.apache.commons.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysq
l://localhost/Timesheets?autoReconnect=true&socketFactory=com.mysql.jdbc
.NamedPipeSocketFactory},{type=password,content=All41a14all},{type=maxWa
it,content=10000},{type=maxActive,content=100},{type=driverClassName,con
tent=org.gjt.mm.mysql.Driver},{type=username,content=timesheet_app},{typ
e=maxIdle,content=30}]
>
>>  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"
reloadable="true"
>          crossContext="true" displayName="ConnectTel Timesheet
Application">
>   <Logger className="org.apache.catalina.logger.FileLogger"
>           prefix="localhost_timesheet_log." suffix=".txt"
timestamp="true"/>
>   <Resource name="jdbc/TimesheetsDB" auth="Container" 
>type="javax.sql.DataSource"/>
>   <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>
> 
><value>jdbc:mysql://localhost/Timesheets?autoReconnect=true&amp;socketF
actory=com.mysql.jdbc.NamedPipeSocketFactory</value>
>     </parameter> 
>
>     <parameter>
>        <name>driverClassName</name> <!-- Class name for mm.mysql 
>JDBC driver -->
>        <value>org.gjt.mm.mysql.Driver</value>
>     </parameter>
>   </ResourceParams>
></Context>
>
>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.  (?)
>
>
>Merrill
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


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



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

Reply via email to