RE: Re: Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Howdy, Yup, but at least it stopped itself at 8 (at a glance) tries ;) I kicked if off yesterday. I'm much more familiar with the list admin functionality following the past couple of week's email craziness. Yoav Shapira Millennium ChemInformatics -Original Message- From: Mike Curwen [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 6:22 PM To: 'Tomcat Users List' Subject: RE: Re: Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling comicbook-guy Stupidest auto-responder *EVER* /comicbook-guy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:15 PM To: [EMAIL PROTECTED] Subject: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - 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] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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-examples-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=truesocketFactory=com.mysql.jdbc.NamedPipeSocketFactory, password=All41a14all, maxWait=1, 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,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql://localhost/Timesheets?autoReconnect=truesocketFactory=com.mysql.jdbc.NamedPipeSocketFactory},{type=password,content=All41a14all},{type=maxWait,content=1},{type=maxActive,content=100},{type=driverClassName,content=org.gjt.mm.mysql.Driver},{type=username,content=timesheet_app},{type=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 descriptionMySql Connection Pool/description res-ref-namejdbc/TimesheetsDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/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 namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter
RE: Another Try at MySQL Connection Pooling
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-userm=107608296706322w=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=truesocketFactory =com.mysql.jdbc.NamedPipeSocketFactory, password=All41a14all, maxWait=1, 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=truesocketFactory=com.mysql.jdbc .NamedPipeSocketFactory},{type=password,content=All41a14all},{type=maxWa it,content=1},{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
RE: Another Try at MySQL Connection Pooling
Oops. Haven't had my coffee yet. I read MySQL but thought SQL Server. Obviously my DB is different than yours, so that may explain our differences. But either way, my previous post might still help. Jay -Original Message- From: Merrill Cornish [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 10, 2004 4:25 PM To: [EMAIL PROTECTED] Subject: Another Try at MySQL Connection Pooling 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-examples -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=truesocketFactory=c om.mysql.jdbc.NamedPipeSocketFactory, password=All41a14all, maxWait=1, 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,fac toryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,cont ent=Shareable},{type=auth,content=Container},{type=factory,content=org.a pache.commons.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql: //localhost/Timesheets?autoReconnect=truesocketFactory=com.mysql.jdbc.N amedPipeSocketFactory},{type=password,content=All41a14all},{type=maxWait ,content=1},{type=maxActive,content=100},{type=driverClassName,conte nt=org.gjt.mm.mysql.Driver},{type=username,content=timesheet_app},{type= 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 descriptionMySql Connection Pool/description res-ref-namejdbc/TimesheetsDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/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 namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name !-- max db connections in the pool -- value100/value !-- 0 implies no limit -- /parameter parameter namemaxIdle/name !-- max idle db connections
RE: Another Try at MySQL Connection Pooling
Jay, Thanks for your comments. I think the problem may be that I don't have the MySQL Connector/J jar in the common/lib. When using DriverManager, it worked fine in jre/lib/ext, which is one of the places the MySQL documentation recommended. I need to try again with it in the new location. Also under DriverManager, the named pipe access worked as advertised. The MySQL instance will be dedicated to my timesheet application and running on the same machine as Tomcat. For security reasons, I don't want MySQL accepting commands over TCP/IP. There is a my.cnf initialization parameter which tells MySQL to not even start up its TCP/IP listener and used named pipes instead. This obviously only works when MySQL is on the same machine as the application, but that's my situation. The named resource factory stuff was carried over from what worked under DriverManager. However, if may have been redundant, but harmless, under DriverManger too, and I just didn't notice. One general problem I'm having with the document I can find is that it tends to simply say, do THIS... without explaining how THIS is doing what it's supposed to be doing. As a result, I'm having trouble reasoning as to what should and should not work. Instead, I'm reduced to plugging in the examples and hoping they work. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
As far as the listening bit is concerned why not just limit mySQL to listen on localhost then? Do you get better performance out of named pipes? -Original Message- From: Merrill Cornish [mailto:[EMAIL PROTECTED] Sent: 11 February 2004 15:52 To: Tomcat Users List Subject: RE: Another Try at MySQL Connection Pooling Jay, Thanks for your comments. I think the problem may be that I don't have the MySQL Connector/J jar in the common/lib. When using DriverManager, it worked fine in jre/lib/ext, which is one of the places the MySQL documentation recommended. I need to try again with it in the new location. Also under DriverManager, the named pipe access worked as advertised. The MySQL instance will be dedicated to my timesheet application and running on the same machine as Tomcat. For security reasons, I don't want MySQL accepting commands over TCP/IP. There is a my.cnf initialization parameter which tells MySQL to not even start up its TCP/IP listener and used named pipes instead. This obviously only works when MySQL is on the same machine as the application, but that's my situation. The named resource factory stuff was carried over from what worked under DriverManager. However, if may have been redundant, but harmless, under DriverManger too, and I just didn't notice. One general problem I'm having with the document I can find is that it tends to simply say, do THIS... without explaining how THIS is doing what it's supposed to be doing. As a result, I'm having trouble reasoning as to what should and should not work. Instead, I'm reduced to plugging in the examples and hoping they work. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. Note:__ This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Jaguar Freight Services and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs.
Re: Another Try at MySQL Connection Pooling
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yiannis Mavroukakis wrote: As far as the listening bit is concerned why not just limit mySQL to listen on localhost then? Do you get better performance out of named pipes? On most versions of Windows, using JDBC and MySQL with named pipes will give you a 50-60% performance improvement. It depends on the particular version of Windows (first, it has to be NT-based, secondly the newer the better). -Mark - -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 332 0507 www.mysql.com Meet the MySQL Team! April 14-16, 2004 http://www.mysql.com/uc2004/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFAKlT0tvXNTca6JD8RAlLAAJwOqL4QfjEAhc69HSI0VYBerWLT3QCgr+Pt 5JI/y54R11o7k6xyezVJ6Io= =Ay3a -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
Hi! Mark Matthews wrote: On most versions of Windows, using JDBC and MySQL with named pipes will give you a 50-60% performance improvement. Which IMO is by no way an intidator of Win's greatness in named pipes but rather of it's bad TCP implementation. Instead of relying on named pipes one should concider switching operation systems on the hosting machine... Just my 2 cent Phil -- And on the seventh day, He exited from append mode. (Book of create(2), line 255) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
I'll add another 2 to the pool :) -Original Message- From: Philipp Taprogge [mailto:[EMAIL PROTECTED] Sent: 11 February 2004 16:24 To: Tomcat Users List Subject: Re: Another Try at MySQL Connection Pooling Hi! Mark Matthews wrote: On most versions of Windows, using JDBC and MySQL with named pipes will give you a 50-60% performance improvement. Which IMO is by no way an intidator of Win's greatness in named pipes but rather of it's bad TCP implementation. Instead of relying on named pipes one should concider switching operation systems on the hosting machine... Just my 2 cent Phil -- And on the seventh day, He exited from append mode. (Book of create(2), line 255) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. Note:__ This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Jaguar Freight Services and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs.
RE: Another Try at MySQL Connection Pooling
I think I read the using named pipes is faster, but that's not going to be a problem here. If I can't get named pipes to work, then I'll try using TCP/IP restricted to localhost. Actually, this whole DataSource experiment has a questionable return on investment. I already have it working just fine with DriverManager using nothing more than the little README file what comes with MySQL's Connector/J download. However, I'd read that DataSource was the way to go for the future, so I thought that switching from DriverManger to DataSource would be a good exercise. So far, all this exercise has given me is sore muscles. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
David, I THINK I've figure out that MySQL's Connector/J jar worked in jre/lib/ex when I was using DriverManager because only MySQL needed to see it, and it knew to look in jre/lib/ex. However, with DataSource, I'm assuming it's Tomcat who needs to see it, so it needs to be in Tomcat's common/lib. So I put Connect/J's jar in common/lib--and it still failed in the same manner. I'm wondering if the actual error message MIGHT be giving a clue. It says Name jdbc is not bound in this Context when the only thing that EVER appears in any of the XML is jdbc/TimesheetsDB. * Does this imply that jdbc/TimesheetsDB is wrong and the entries should be something like simply TimesheetsDB? * Does this imply that jdbc has to be declared in some manner before jdbc/TimesheetsDB can be declared? Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
Merrill, Much of what you're doing is just beyond me but I can't help but noticing this in your first post. parameter namepassword/name valuexxx/value /parameter Since you've included a password value in all the other places I'm wondering if the lack of it here could be part of the problem. Sorry if I'm way off base, Ken -Original Message- From: Merrill Cornish [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 10, 2004 5:25 PM To: [EMAIL PROTECTED] Subject: Another Try at MySQL Connection Pooling 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-examples-how to.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=truesocketFactory=com.m ysql.jdbc.NamedPipeSocketFactory, password=All41a14all, maxWait=1, 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,factory ClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shar eable},{type=auth,content=Container},{type=factory,content=org.apache.common s.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql://localhost/Time sheets?autoReconnect=truesocketFactory=com.mysql.jdbc.NamedPipeSocketFactor y},{type=password,content=All41a14all},{type=maxWait,content=1},{type=ma xActive,content=100},{type=driverClassName,content=org.gjt.mm.mysql.Driver}, {type=username,content=timesheet_app},{type=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 descriptionMySql Connection Pool/description res-ref-namejdbc/TimesheetsDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/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 namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name !-- max db connections in the pool
RE: Another Try at MySQL Connection Pooling
I forgot whether your original post showed it or not, but how are you trying to acquire the resource in your code? It should look something like: Context initialContext = new InitialContext(); Context envContext = (Context) initialContext.lookup(java:comp/env); this.dataSource = (DataSource) envContext.lookup(jdbc/TimesheetsDB ); Just a thought, in case you've got one of the strings wrong. Jay -Original Message- From: Merrill Cornish [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 11:43 AM To: Tomcat Users List Subject: Re: Another Try at MySQL Connection Pooling David, I THINK I've figure out that MySQL's Connector/J jar worked in jre/lib/ex when I was using DriverManager because only MySQL needed to see it, and it knew to look in jre/lib/ex. However, with DataSource, I'm assuming it's Tomcat who needs to see it, so it needs to be in Tomcat's common/lib. So I put Connect/J's jar in common/lib--and it still failed in the same manner. I'm wondering if the actual error message MIGHT be giving a clue. It says Name jdbc is not bound in this Context when the only thing that EVER appears in any of the XML is jdbc/TimesheetsDB. * Does this imply that jdbc/TimesheetsDB is wrong and the entries should be something like simply TimesheetsDB? * Does this imply that jdbc has to be declared in some manner before jdbc/TimesheetsDB can be declared? 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]
Re: Another Try at MySQL Connection Pooling
Merrill, I may end up eating a little sole, but I have had shoe before. Your name for the jdbc is wrong. It should be: !-- Class name for mm.mysql JDBC driver -- parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter Yeah, I know the notes said otherwise. They were written prior to MySQL taking on the drivers officially. As for jdbc/TimesheetsDB it should be fine. Let us know Doug Parsons www.parsonstechnical.com - Original Message - From: Merrill Cornish [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 12:43 PM Subject: Re: Another Try at MySQL Connection Pooling David, I THINK I've figure out that MySQL's Connector/J jar worked in jre/lib/ex when I was using DriverManager because only MySQL needed to see it, and it knew to look in jre/lib/ex. However, with DataSource, I'm assuming it's Tomcat who needs to see it, so it needs to be in Tomcat's common/lib. So I put Connect/J's jar in common/lib--and it still failed in the same manner. I'm wondering if the actual error message MIGHT be giving a clue. It says Name jdbc is not bound in this Context when the only thing that EVER appears in any of the XML is jdbc/TimesheetsDB. * Does this imply that jdbc/TimesheetsDB is wrong and the entries should be something like simply TimesheetsDB? * Does this imply that jdbc has to be declared in some manner before jdbc/TimesheetsDB can be declared? 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]
Re: Another Try at MySQL Connection Pooling
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Parsons Technical Services wrote: Merrill, I may end up eating a little sole, but I have had shoe before. Your name for the jdbc is wrong. It should be: !-- Class name for mm.mysql JDBC driver -- parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter Yeah, I know the notes said otherwise. They were written prior to MySQL taking on the drivers officially. Actually, either works (we've left in 'org.gjt.mm.mysql.Driver' for backwards-compatibility). Whenever I've had problems with this, I've found that I'm usually using the wrong strings/formats for the ENV namespace (as a previous poster has talked about), or I messed around with the tomcat configuration too much...Try and use the example they've provided, if you use it out of the box, it works (for most people), and then change one thing at a time. Unfortunately, Tomcat itself doesn't complain much up front when you have something wrong with configuration, and it usually manifests itself as an exception that's not related to what you've misconfigured :( Regards, -Mark - -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 332 0507 www.mysql.com Meet the MySQL Team! April 14-16, 2004 http://www.mysql.com/uc2004/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFAKoOFtvXNTca6JD8RAnj2AKCgLDOhFTqqb/EgUKydHwIBdJc4cwCglp/l oDTq3EIy2zKuLxv+UawytXQ= =b4W4 -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
Jay, Context initialContext = new InitialContext(); Context envContext = (Context) initialContext.lookup(java:comp/env); this.dataSource = (DataSource) envContext.lookup(jdbc/TimesheetsDB ); Ah ha! I was missing the second step. When I added the second step, it still fails, but the complaint has changed. Slightly. At org.apache.naming.NamingContext.lookup(NamingContext.java:814) there occurred a javax.naming.NameNotFoundException: Name TimesheetsDB is not bound in this Context So now it can find jdbc, but not TimesheetsDB. By the way, what does the java:comp/env argument mean? Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
Doug, I noticed the class name discrepancy myself between the name I had used for DriverManager and the one the DataSource example had. However, when I peeked inside the Connector/J jar file, I found both .class files, altough they are of different sizes. I tried it with your alternative, but the error is the same either way: At org.apache.naming.NamingContext.lookup(NamingContext.java:814) there occurred a javax.naming.NameNotFoundException: Name TimesheetsDB is not bound in this Context - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
Mmmm...Not too bad with a little salt. During my initial setup I was unable to get it to work with the old name. Just tested it and it works fine. I would have to lay odds that I had a typo originally. - Original Message - From: Mark Matthews [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Cc: Merrill Cornish [EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 2:33 PM Subject: Re: Another Try at MySQL Connection Pooling -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Parsons Technical Services wrote: Merrill, I may end up eating a little sole, but I have had shoe before. Your name for the jdbc is wrong. It should be: !-- Class name for mm.mysql JDBC driver -- parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter Yeah, I know the notes said otherwise. They were written prior to MySQL taking on the drivers officially. Actually, either works (we've left in 'org.gjt.mm.mysql.Driver' for backwards-compatibility). Whenever I've had problems with this, I've found that I'm usually using the wrong strings/formats for the ENV namespace (as a previous poster has talked about), or I messed around with the tomcat configuration too much...Try and use the example they've provided, if you use it out of the box, it works (for most people), and then change one thing at a time. Unfortunately, Tomcat itself doesn't complain much up front when you have something wrong with configuration, and it usually manifests itself as an exception that's not related to what you've misconfigured :( Regards, -Mark - -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 332 0507 www.mysql.com Meet the MySQL Team! April 14-16, 2004 http://www.mysql.com/uc2004/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFAKoOFtvXNTca6JD8RAnj2AKCgLDOhFTqqb/EgUKydHwIBdJc4cwCglp/l oDTq3EIy2zKuLxv+UawytXQ= =b4W4 -END PGP SIGNATURE- - 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]
RE: Another Try at MySQL Connection Pooling
Ken, I didn't intend to include the password in ANY of my posts, but I guess some slipped though. In the version that running, the password is there. And, even if I had fumble fingered the password, THAT would have simply gotten a convention MySQL error rather than a NameNotFoundException for jdbc. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
The J2EE tutorial is one place that talks about the context naming scheme: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Resources2.html And just to be 100% sure, my example below actually has a minor cut-and-paste error--there's a space after TimesheetsDB in the second lookup(). If you simply cut-and-pasted my example, and it turns out that the string has to be an exact match, then this could be an issue. Probably not, but worth mentioning, just in case. Jay -Original Message- From: Merrill Cornish [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 2:04 PM To: Tomcat Users List Subject: RE: Another Try at MySQL Connection Pooling Jay, Context initialContext = new InitialContext(); Context envContext = (Context) initialContext.lookup(java:comp/env); this.dataSource = (DataSource) envContext.lookup(jdbc/TimesheetsDB ); Ah ha! I was missing the second step. When I added the second step, it still fails, but the complaint has changed. Slightly. At org.apache.naming.NamingContext.lookup(NamingContext.java:814) there occurred a javax.naming.NameNotFoundException: Name TimesheetsDB is not bound in this Context So now it can find jdbc, but not TimesheetsDB. By the way, what does the java:comp/env argument mean? 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]
Re: Another Try at MySQL Connection Pooling
I have another shoe to go so try this. Try changing the name to: parameter nameurl/name valuejdbc:mysql://localhost/timesheets?.. Lower case on the timesheets. I am running on linux. Not sure if it will matter on windows. Doug - Original Message - From: Merrill Cornish [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 2:27 PM Subject: RE: Another Try at MySQL Connection Pooling Ken, I didn't intend to include the password in ANY of my posts, but I guess some slipped though. In the version that running, the password is there. And, even if I had fumble fingered the password, THAT would have simply gotten a convention MySQL error rather than a NameNotFoundException for jdbc. 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]
Re: Another Try at MySQL Connection Pooling
Merrill, you should be absolutely sure that your context is getting loaded from the file you think. Make sure that there is no context config for the app in any of the other files in tomcat/conf/Catalina/localhost, nor in server.xml, nor in META-INF in any webapp directory. You can chuck out the resource-ref from the web.xml - I'm using 3 JNDI connection pools and I don't have it in my web.xml (is that macho?) - just don't ask me why. Adam On 02/11/2004 09:13 PM Burgess, Jay S wrote: The J2EE tutorial is one place that talks about the context naming scheme: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Resources2.html And just to be 100% sure, my example below actually has a minor cut-and-paste error--there's a space after TimesheetsDB in the second lookup(). If you simply cut-and-pasted my example, and it turns out that the string has to be an exact match, then this could be an issue. Probably not, but worth mentioning, just in case. Jay -Original Message- From: Merrill Cornish [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 2:04 PM To: Tomcat Users List Subject: RE: Another Try at MySQL Connection Pooling Jay, Context initialContext = new InitialContext(); Context envContext = (Context) initialContext.lookup(java:comp/env); this.dataSource = (DataSource) envContext.lookup(jdbc/TimesheetsDB ); Ah ha! I was missing the second step. When I added the second step, it still fails, but the complaint has changed. Slightly. At org.apache.naming.NamingContext.lookup(NamingContext.java:814) there occurred a javax.naming.NameNotFoundException: Name TimesheetsDB is not bound in this Context So now it can find jdbc, but not TimesheetsDB. By the way, what does the java:comp/env argument mean? 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] -- struts 1.1 + tomcat 5.0.16 + java 1.4.2 Linux 2.4.20 Debian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
Doug, Timesheet vs. timesheet Good catch, but it didn't make any difference. I originally had three Context entries for names Timesheet, (the way I thought of it), timesheet (for those who don't want to use the shift key), and ts (for those diehard Unix freaks who believe anything worth doing should be done in three characters or less). The actual directory under webapps is timesheets. I've edited timesheet.xml (note the lower case) to match the directory, but the result was unchanged. Thanks for the thoughts, though. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
Adam, The following line occurs in stdout.log: INFO: Processing Context configuration file URL file:C:\Program Files\Apache Group\Tomcat 5.0.18\conf\Catalina\localhost\timesheet.xml so it appears to be getting the correct context fragment. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
On 02/11/2004 10:15 PM Merrill Cornish wrote: Adam, The following line occurs in stdout.log: INFO: Processing Context configuration file URL file:C:\Program Files\Apache Group\Tomcat 5.0.18\conf\Catalina\localhost\timesheet.xml so it appears to be getting the correct context fragment. What if that fragment is an old one you accidentally left hanging around? -- struts 1.1 + tomcat 5.0.16 + java 1.4.2 Linux 2.4.20 Debian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
Merrill, Humor me for a moment. This might be due to you trying different setups, but, take a minute to go through all your settings and names and make sure that they are all set to the same thing and the same case. In the line below it is refering to timesheet.xml and earlier you had timesheets. I made the same mistakes in my initial setup. In my prior post my concern was that the jdbc was refered to uppercase T and the docs were lower case t. On linux you can't do this. All references must be exactly the same. So anywhere you use the word timesheets in any form, make it the same. Let's just say I'm shiny on top and little things like this didn't help. Doug Parsons www.parsonstechnical.com - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 4:30 PM Subject: Re: Another Try at MySQL Connection Pooling On 02/11/2004 10:15 PM Merrill Cornish wrote: Adam, The following line occurs in stdout.log: INFO: Processing Context configuration file URL file:C:\Program Files\Apache Group\Tomcat 5.0.18\conf\Catalina\localhost\timesheet.xml so it appears to be getting the correct context fragment. What if that fragment is an old one you accidentally left hanging around? -- struts 1.1 + tomcat 5.0.16 + java 1.4.2 Linux 2.4.20 Debian - 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]
Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
auto-reply sucks for mailing lists... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 4:11 PM To: [EMAIL PROTECTED] Subject: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contresena. Gracias por confiar en nosotros - 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]
Re: Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RE: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
I really hope you can get this figured out, as I'm out of ideas. But I do concur with Adam's suggestion about looking for multiple contexts, as I ran into a similar problem when my context.xml was there twice--once in my .WAR, and once as a result of my Ant deploy task putting it manually into conf\Catalina\localhost. Having two copies caused odd problems. Finally, I notice from your original post that you're running Tomcat as a service. Have you tried running it manually? I've had issues with other apps that are directly related my app trying to run as a service. Jay -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 3:56 PM To: Tomcat Users List Subject: Re: Another Try at MySQL Connection Pooling Merrill, Humor me for a moment. This might be due to you trying different setups, but, take a minute to go through all your settings and names and make sure that they are all set to the same thing and the same case. In the line below it is refering to timesheet.xml and earlier you had timesheets. I made the same mistakes in my initial setup. In my prior post my concern was that the jdbc was refered to uppercase T and the docs were lower case t. On linux you can't do this. All references must be exactly the same. So anywhere you use the word timesheets in any form, make it the same. Let's just say I'm shiny on top and little things like this didn't help. Doug Parsons www.parsonstechnical.com - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 4:30 PM Subject: Re: Another Try at MySQL Connection Pooling On 02/11/2004 10:15 PM Merrill Cornish wrote: Adam, The following line occurs in stdout.log: INFO: Processing Context configuration file URL file:C:\Program Files\Apache Group\Tomcat 5.0.18\conf\Catalina\localhost\timesheet.xml so it appears to be getting the correct context fragment. What if that fragment is an old one you accidentally left hanging around? -- struts 1.1 + tomcat 5.0.16 + java 1.4.2 Linux 2.4.20 Debian - 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]
Re: Another Try at MySQL Connection Pooling
Doug, The application directory under webapps is named timesheet, therefore, the context fragment in conf/Catalina/localhost is timesheet.xml to match the context name. The beginning of the Context element in timesheet.xml is Context path=/timesheet docBase=timesheet . . . to match the directory name under webapps. So, I think as far as Tomcat goes, I've got it consistently as timesheet. The class name under webapps/timesheet/WEB_INF/classes is Timesheet to follow the Java capitalization conventions of class names. Therefore, Timesheet appears in my web.xml as the prefix to the various servlet-class names, but nowhere else. Now, as for the MySQL database, I named it Timesheets (note the capital and the plural). My logic being that the application was for doing a single timesheet at a time while the database was for recording all the timesheets at once. (Yes, I'm anal. I know. :-) ). The database name shows up in the url parameter: jdbc:mysql://localhost/Timesheets?... In that case the plural is critical, but the capitalization isn't (in my case) since a MySQL database name is merely a file name and file names in Windows are case insensitive. Nevertheless, I've got it matching. As far as I can tell, this URL is the only place in the Tomcat configuration files that the name of the MySQL database appears. Unless... Now we come to Resource name=jdbc/TimesheetsDB ... / ResourceParams name=jdbc/TimesheetsDB ... /ResourceParams I was just reading up on the JNI naming conventions from a link someone gave me when I stopped to check my mail again. As nearly as I can tell, the jdbc part of the jdbc/TimesheetsDB is magic, and it must be that to work. However, the TimesheetsDB part can be anything you want as long as the name attributes in Resource and ResourceParams matches. Therefore, I used Timesheets to reflect the MySQL database name and DB just because the first example I saw used that suffix. I think I've got all that consistent, but if DataSource is supposed to be the way to go in the future for JDBC, it shouldn't be this hard. By the way, I do appreciate the time you're spending thinking about my problem. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
Jay, once in my .WAR, and once as a result of my Ant deploy task I have yet to move to that plane of confusion. I'm not using a META-INF directory or a .WAR file since I'm still trying to figure out WHAT to deploy. I am manually editing * the conf/server.xml file (to change the default ports, but nothing else), * the webapps/timesheet/* directory (to hold the application), * the webapps/WEB-INF/web.xml file (to name and map the various servlets, etc.), and * conf/Cataline/localhost/timesheet.xml (to define the context). I think it's time I reverted to DriverManager and got on with other things. While Tomcat DataSources are proved to be a learning experience with a vengance, it hasn't been a very positive one. :-( Nevertheless, thanks for your help and support. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another Try at MySQL Connection Pooling
Well, it's not that I'm an expert... I actually have had that problem once or twice, and most of the time the problem was in the context.xml I've always specified my webapps' Context in a separated file (which I believe you're also doing), but when I messed up with server.xml I had some namingExceptions like that one. I saw then that I was defining a Resource element OUTSIDE the Context scope. Once, it was from a completely different webapp (ps!) and later on, I has the same error when trying to access a Resource created my the admin webapp. So, since then, I always code manually the Resource element inside the Context in my context.xml. It kept me out of trouble so far, and no more namingExceptions... Maybe it's a coincidence, maybe that's not why you're getting that Exception, but it's worth a check up. Make sure your Resource is inside the Context and, just in case, code it again (don't copy/paste, just in case). If that's not working, you'll only have wasted 15 minutes... Good luck! Ken - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Try at MySQL Connection Pooling
Okay, Grasping at straws now, but otherwise out of ideas. 1. Can you ping localhost successfully? If no change url to IP of machine. 2. Do you have a firewall running on the machine? Disable it. 3. Anyone had any problems with naming conventions? Change timesheets to tmsheets. 8+3 4. When you go to driver manager use cut and paste to input your information. If it works with driver manager then you know that at least that information has been enter without error. I don't think that the socks will taste as good. Doug Parsons www.parsonstechnical.com PS. If you like I can send you a copy of my files. Two differences: I am on linux and 4.1.29. - Original Message - From: Merrill Cornish [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM Subject: RE: Another Try at MySQL Connection Pooling Jay, once in my .WAR, and once as a result of my Ant deploy task I have yet to move to that plane of confusion. I'm not using a META-INF directory or a .WAR file since I'm still trying to figure out WHAT to deploy. I am manually editing * the conf/server.xml file (to change the default ports, but nothing else), * the webapps/timesheet/* directory (to hold the application), * the webapps/WEB-INF/web.xml file (to name and map the various servlets, etc.), and * conf/Cataline/localhost/timesheet.xml (to define the context). I think it's time I reverted to DriverManager and got on with other things. While Tomcat DataSources are proved to be a learning experience with a vengance, it hasn't been a very positive one. :-( Nevertheless, thanks for your help and support. 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]
Re: Another Try at MySQL Connection Pooling
Merrill, I think everyone's waiting to see you kick yourself when you discover what the problem is... ;) No seriously, there are 2 things that I would try - (1) debug the context - I think it returns an enum of entries available from some method, and (2) go back to the most basic test servlet / jsp, context.xml web.xml, and a clean install of tomcat and try it there. Also check your Host settings in server.xml. Is deployXML=true? I think it should be. As far as a learning experience goes, I think giving it up as a bad thing now would only be a negative experience, whereas actually finding out what is wrong and fixing it, well as long as it doesn't take too long. On 02/11/2004 11:34 PM Merrill Cornish wrote: Jay, once in my .WAR, and once as a result of my Ant deploy task I have yet to move to that plane of confusion. I'm not using a META-INF directory or a .WAR file since I'm still trying to figure out WHAT to deploy. I am manually editing * the conf/server.xml file (to change the default ports, but nothing else), * the webapps/timesheet/* directory (to hold the application), * the webapps/WEB-INF/web.xml file (to name and map the various servlets, etc.), and * conf/Cataline/localhost/timesheet.xml (to define the context). I think it's time I reverted to DriverManager and got on with other things. While Tomcat DataSources are proved to be a learning experience with a vengance, it hasn't been a very positive one. :-( Nevertheless, thanks for your help and support. Merrill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.16 + java 1.4.2 Linux 2.4.20 Debian - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Re: Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling
comicbook-guy Stupidest auto-responder *EVER* /comicbook-guy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:15 PM To: [EMAIL PROTECTED] Subject: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Another Try at MySQL Connection Pooling Ya hemos recibido su solicitud de correo en breve le enviaremos su nombre de usuario y contreseña. Gracias por confiar en nosotros - 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]
Re: Another Try at MySQL Connection Pooling
This is what works for me - (see NOTES at end - if anyone can shed any light on Limiting Pool size) #1in your Server.xml GlobalNamingResources Resource name=MySQLDataSourceFactory type=com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource auth=Container/ ResourceParams name=MySQLDataSourceFactory parameter namefactory/name valuecom.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory/value /parameter parameter nameport/name value3306/value /parameter parameter nameuser/name valuedbUsername/value /parameter parameter namepassword/name valuedbUserPassword/value /parameter parameter nameserverName/name valuedbHostIP_Name/value /parameter parameter namedatabaseName/name valuedbName/value /parameter /ResourceParams . /GlobalNamingResources #2in your Context section (either in its own context fragment file or Context section of server.xml) Context className=org.apache.catalina.core.StandardContext backgroundProcessorDelay=-1 cachingAllowed=true charsetMapperClass=org.apache.catalina.util.CharsetMapper configFile=..\Catalina\localhost\yourContextFragment.xml * NOT req'd if your Context is defined in server.xml cookies=true crossContext=false debug=9 displayName=Your webApp name to be displayed in webApp manager docBase=../yourWebApp.war * NOT req'd if deploying via Tomcat WebApp manager - see NOTEs below domain=Catalina engineName=Catalina j2EEApplication=none j2EEServer=none lazy=true managerChecksFrequency=6 path=/yourWebAppContextPath privileged=false reloadable=false startupTime=47 swallowOutput=false tldScanTime=875 useNaming=true wrapperClass=org.apache.catalina.core.StandardWrapper ResourceLink global=MySQLDataSourceFactory the JNDI name as defined in GlobalNamingResources|Resource name=jdbc/yourJNDIResourceDBName the JNDI name as used in your webApp code - see below type=javax.sql.DataSource/ /Context #3you can test this with the following code fragment System.out.println(Getting Context info); Context initCtx = new InitialContext(); System.out.println(Got Initial Context); Context envCtx = (Context)initCtx.lookup(java:comp/env); System.out.println(Got JWSDP Environment Context); try{ System.out.println(Getting MySQL DataSource); DataSource ds = (DataSource)envCtx.lookup(jdbc/yourJNDIResourceDBName); if(ds != null) { System.out.println(Got MySQL DataSource); Vector vConns = new Vector(); try{ for(int i = 0; i SOMEREASONABLYLARGENUMBER; i++) { vConns.add(ds.getConnection()); System.out.println(Got MySQL DB Connection ' + i + ' from Pool); } }catch(Exception eX){ eX.printStackTrace(); }finally{ //*Don't forget to release the DB Connections** Iterator iT = vConns.iterator(); while(iT.hasNext()) { Connection conn = (Connection)iT.next(); conn.close(); } } } else System.out.println(NULL MySQL DataSource); }catch(Exception eX){ eX.printStackTrace(); } NOTEs 1 you do NOT need a resource-ref entry in you web.xml - the ResourceLink / in your Context definition is an alternative mechanism provides the JNDI name translation from your webApp world to the GLOBAL name in the Container world 2Tomcat WebAdmin tool does NOT show this connection pool in Resource|Data Sources (so don't waste time looking for it) 3Apparently you can build the Context fragment into the WAR file (will check this next as it means you can have a self contained webApp that you can deploy easily via Tomcat Web Manager without Stopping/starting Tomcat all the time) 4Make sure the MySQL jar file (mysql-connector-java-3.0.10-stable-bin.jar) is in ...Tomact_Install_Dir\common\lib 5using the jdbc prefix to yourJNDIResourceDBName is just a CONVENTION - you don'y have to comply with it Hope this is of use Any comments/corrections please post a reply Stefan -- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] Merrill Cornish [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 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
Another Try at MySQL Connection Pooling
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-examples-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=truesocketFactory=com.mysql.jdbc.NamedPipeSocketFactory, password=All41a14all, maxWait=1, 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,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql://localhost/Timesheets?autoReconnect=truesocketFactory=com.mysql.jdbc.NamedPipeSocketFactory},{type=password,content=All41a14all},{type=maxWait,content=1},{type=maxActive,content=100},{type=driverClassName,content=org.gjt.mm.mysql.Driver},{type=username,content=timesheet_app},{type=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 descriptionMySql Connection Pool/description res-ref-namejdbc/TimesheetsDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/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 namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name !-- max db connections in the pool -- value100/value !-- 0 implies no limit -- /parameter parameter namemaxIdle/name !-- max idle db connections to retain in pool -- value30/value !-- 0 implies no limit -- /parameter parameter namemaxWait/name !-- max wait for connection before throwing exception -- value1/value !-- -1 implies no limit (time is in milliseconds) -- /parameter parameter nameusername/name valuetimesheet_app/value /parameter