Re: Kumar's JDBC problems with MySQL
If you are having problems with JNDI connection pooling and you can't work out the problem, I would pay attention to the Host node settings in the server.xml. I would even get a fresh installation of tomcat and start from scratch with a simple test case. The attributes of Host, e.g. autoDeploy, deployOnStartup, deployXML, unpackWARs can be combined in ways that will not load the JNDI context, definitely when deploying WAR files and possibly under other circumstances. I've had it happen to me myself, and I've seen other comment on it here but sadly for you I didn't document it. Just saying though, it's worth going back to square one. Adam On 03/18/2004 05:42 AM Steve Gums wrote: I noticed a couple things. One I want to be corrected if I am wrong but your docBase should not be root. Second your driver for MySQL isn't the org.gjt thing anymore. Use com.mysql.jdbc.Driver I unfortunately have seen this error far too much in the past few days. It is not getting into the JNDI resources. Your context segment needs repair. Steve I have included my DBTest.xml from /usr/local/tomcat/conf/Catalina/localhost/ and it works now. Context path=/DBTest docBase=DBTest debug=5 reloadable=true crossContext=true Logger className=org.apache.catalina.logger.FileLogger prefix=localhost_DBTest_log. suffix=.txt timestamp=true/ Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/TestDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter !-- Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to 0 for no limit. -- parameter namemaxActive/name value100/value /parameter !-- Maximum number of idle dB connections to retain in pool. Set to 0 for no limit. -- parameter namemaxIdle/name value30/value /parameter !-- Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. -- parameter namemaxWait/name value1/value /parameter !-- MySQL dB username and password for dB connections -- parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter !-- Class name for mm.mysql JDBC driver -- parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter !-- The JDBC connection url for connecting to your MySQL dB. The autoReconnect=true argument to the url makes sure that the mm.mysql JDBC Driver will automatically reconnect if mysqld closed the connection. mysqld by default closes idle connections after 8 hours. -- parameter nameurl/name valuejdbc:mysql://localhost/javatest?autoReconnect=true/value /parameter /ResourceParams /Context -Original Message- From: Kawthar Bt M Sulaiman [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 7:32 PM To: [EMAIL PROTECTED] Subject: Re: Kumar's JDBC problems with MySQL Kumar, I've been trying to follow the JDBC pb thread as well and still can't get rid of the problem. Here is what I've done. Using J Connector 3.0, Tomcat 4.1.30 and mySQL 4.0.18. I put my mysql-connector-java-3.0.11-bin under /common/lib. 1. Start from simple web.xml: resource-ref descriptionDB Connection/description res-ref-namejdbc/mySQLDatabase/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref 2. server.xml (located at $CATALINA_HOME\conf\server.xml) Context path=/db docBase =ROOT debug=9 reloadable=true Resource name=jdbc/mySQLDatabase auth=Shareable type=javax.sql.DataSource description=JDBC Connection to MySQL v4.0.18/ ResourceParams name=jdbc/mySQLDatabase parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameserverName/name valuelocalhost/value /parameter parameter namedatabaseName/name valueecpa/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter
Kumar's JDBC problems with MySQL
Kumar, First, I started you your own thread. I do this so that others and I can keep you straight as to who is who and know it is a seperate issue although on the same topic. Please repost your context portion of the xml, the section of code that accesses the connection pool and if global, the resourse section of the server.xml. We need to see your code to help give you some direction. You can also look back at the thread RE: Problem using JNDI/DBCP to get DataSouce for some pointers as well. As far as I am aware the main difference in TC4 and TC5 when seting up the DBCP is that in TC5 you can use xml fragments in your app and not have to modify your server.xml. List please correct me if I am wrong. Doug www.parsonstechnical.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Kumar's JDBC problems with MySQL
TC4 supports context resource fragments, but not within a war (META-INF/context.xml in TC5)... -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 6:18 PM To: Tomcat Users List Subject: Kumar's JDBC problems with MySQL Kumar, First, I started you your own thread. I do this so that others and I can keep you straight as to who is who and know it is a seperate issue although on the same topic. Please repost your context portion of the xml, the section of code that accesses the connection pool and if global, the resourse section of the server.xml. We need to see your code to help give you some direction. You can also look back at the thread RE: Problem using JNDI/DBCP to get DataSouce for some pointers as well. As far as I am aware the main difference in TC4 and TC5 when seting up the DBCP is that in TC5 you can use xml fragments in your app and not have to modify your server.xml. List please correct me if I am wrong. Doug www.parsonstechnical.com - 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: Kumar's JDBC problems with MySQL
Kumar, I've been trying to follow the JDBC pb thread as well and still can't get rid of the problem. Here is what I've done. Using J Connector 3.0, Tomcat 4.1.30 and mySQL 4.0.18. I put my mysql-connector-java-3.0.11-bin under /common/lib. 1. Start from simple web.xml: resource-ref descriptionDB Connection/description res-ref-namejdbc/mySQLDatabase/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref 2. server.xml (located at $CATALINA_HOME\conf\server.xml) Context path=/db docBase =ROOT debug=9 reloadable=true Resource name=jdbc/mySQLDatabase auth=Shareable type=javax.sql.DataSource description=JDBC Connection to MySQL v4.0.18/ ResourceParams name=jdbc/mySQLDatabase parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameserverName/name valuelocalhost/value /parameter parameter namedatabaseName/name valueecpa/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value200/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namemaxActive/name value100/value /parameter parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/ecpa?autoReconnect=true/value /parameter /ResourceParams Logger className=org.apache.catalina.logger.FileLogger prefix=DBlog. suffix=.txt timestamp=true/ /Context 3. In my code: Context ctx = new InitialContext(); if(ctx == null) { throw new Exception(\nNo Context Error); } DataSource ds = (DataSource) ctx.lookup(java:comp/env/jdbc/mySQLDatabase); if (ds == null) { System.out.println(\n DataSource is NULL ); } Connection conn = ds.getConnection(); if (conn != null) { System.out.println(\nGot Connection ); Statement stmt = conn.createStatement(); ResultSet rst = stmt.executeQuery(select username from users); if(rst.next()) { System.out.println(\n username: + rst.getString(1)); } conn.close(); } 4. Error message I got from printStackTrace(): org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' ' for connect URL 'null', cause: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:743) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource .java:518) at com.maxis.app.ContentProcessor.initializeDatabase(ContentProcessor.ja va:60) at com.maxis.morequest.DBTest.init(DBTest.java:31) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:935) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.jav a:668) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:210) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) I believe these are the steps everybody else implementing, but I still get this error... Did I miss something? Thanks, --Kawthar Confidential information may be contained in this e-mail
Re: Kumar's JDBC problems with MySQL
Kawthar, Remove this from the context: parameter namedatabaseName/name valueecpa/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter The database name is given in the url and the pathname is for a file base system. Try it again and let us know in a new thread. Doug Parsons www.parsonstechnical.com - Original Message - From: Kawthar Bt M Sulaiman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 9:32 PM Subject: Re: Kumar's JDBC problems with MySQL Kumar, I've been trying to follow the JDBC pb thread as well and still can't get rid of the problem. Here is what I've done. Using J Connector 3.0, Tomcat 4.1.30 and mySQL 4.0.18. I put my mysql-connector-java-3.0.11-bin under /common/lib. 1. Start from simple web.xml: resource-ref descriptionDB Connection/description res-ref-namejdbc/mySQLDatabase/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref 2. server.xml (located at $CATALINA_HOME\conf\server.xml) Context path=/db docBase =ROOT debug=9 reloadable=true Resource name=jdbc/mySQLDatabase auth=Shareable type=javax.sql.DataSource description=JDBC Connection to MySQL v4.0.18/ ResourceParams name=jdbc/mySQLDatabase parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameserverName/name valuelocalhost/value /parameter parameter namedatabaseName/name valueecpa/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value200/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namemaxActive/name value100/value /parameter parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/ecpa?autoReconnect=true/value /parameter /ResourceParams Logger className=org.apache.catalina.logger.FileLogger prefix=DBlog. suffix=.txt timestamp=true/ /Context 3. In my code: Context ctx = new InitialContext(); if(ctx == null) { throw new Exception(\nNo Context Error); } DataSource ds = (DataSource) ctx.lookup(java:comp/env/jdbc/mySQLDatabase); if (ds == null) { System.out.println(\n DataSource is NULL ); } Connection conn = ds.getConnection(); if (conn != null) { System.out.println(\nGot Connection ); Statement stmt = conn.createStatement(); ResultSet rst = stmt.executeQuery(select username from users); if(rst.next()) { System.out.println(\n username: + rst.getString(1)); } conn.close(); } 4. Error message I got from printStackTrace(): org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' ' for connect URL 'null', cause: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:743) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource .java:518) at com.maxis.app.ContentProcessor.initializeDatabase(ContentProcessor.ja va:60) at com.maxis.morequest.DBTest.init(DBTest.java:31) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:935) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.jav a:668) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:210) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643
RE: Kumar's JDBC problems with MySQL
After figuring out all the details.. I just want to pass along to the developers that read this list. I LOVE IT! That is the way to go, it helps keep the server.xml clean and manageable. Thanks -Original Message- From: D'Alessandro, Arthur [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 5:22 PM To: Tomcat Users List Subject: RE: Kumar's JDBC problems with MySQL TC4 supports context resource fragments, but not within a war (META-INF/context.xml in TC5)... -Original Message- From: Parsons Technical Services [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 6:18 PM To: Tomcat Users List Subject: Kumar's JDBC problems with MySQL Kumar, First, I started you your own thread. I do this so that others and I can keep you straight as to who is who and know it is a seperate issue although on the same topic. Please repost your context portion of the xml, the section of code that accesses the connection pool and if global, the resourse section of the server.xml. We need to see your code to help give you some direction. You can also look back at the thread RE: Problem using JNDI/DBCP to get DataSouce for some pointers as well. As far as I am aware the main difference in TC4 and TC5 when seting up the DBCP is that in TC5 you can use xml fragments in your app and not have to modify your server.xml. List please correct me if I am wrong. Doug www.parsonstechnical.com - 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: Kumar's JDBC problems with MySQL
I noticed a couple things. One I want to be corrected if I am wrong but your docBase should not be root. Second your driver for MySQL isn't the org.gjt thing anymore. Use com.mysql.jdbc.Driver I unfortunately have seen this error far too much in the past few days. It is not getting into the JNDI resources. Your context segment needs repair. Steve I have included my DBTest.xml from /usr/local/tomcat/conf/Catalina/localhost/ and it works now. Context path=/DBTest docBase=DBTest debug=5 reloadable=true crossContext=true Logger className=org.apache.catalina.logger.FileLogger prefix=localhost_DBTest_log. suffix=.txt timestamp=true/ Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/TestDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter !-- Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to 0 for no limit. -- parameter namemaxActive/name value100/value /parameter !-- Maximum number of idle dB connections to retain in pool. Set to 0 for no limit. -- parameter namemaxIdle/name value30/value /parameter !-- Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. -- parameter namemaxWait/name value1/value /parameter !-- MySQL dB username and password for dB connections -- parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter !-- Class name for mm.mysql JDBC driver -- parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter !-- The JDBC connection url for connecting to your MySQL dB. The autoReconnect=true argument to the url makes sure that the mm.mysql JDBC Driver will automatically reconnect if mysqld closed the connection. mysqld by default closes idle connections after 8 hours. -- parameter nameurl/name valuejdbc:mysql://localhost/javatest?autoReconnect=true/value /parameter /ResourceParams /Context -Original Message- From: Kawthar Bt M Sulaiman [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 7:32 PM To: [EMAIL PROTECTED] Subject: Re: Kumar's JDBC problems with MySQL Kumar, I've been trying to follow the JDBC pb thread as well and still can't get rid of the problem. Here is what I've done. Using J Connector 3.0, Tomcat 4.1.30 and mySQL 4.0.18. I put my mysql-connector-java-3.0.11-bin under /common/lib. 1. Start from simple web.xml: resource-ref descriptionDB Connection/description res-ref-namejdbc/mySQLDatabase/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref 2. server.xml (located at $CATALINA_HOME\conf\server.xml) Context path=/db docBase =ROOT debug=9 reloadable=true Resource name=jdbc/mySQLDatabase auth=Shareable type=javax.sql.DataSource description=JDBC Connection to MySQL v4.0.18/ ResourceParams name=jdbc/mySQLDatabase parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameserverName/name valuelocalhost/value /parameter parameter namedatabaseName/name valueecpa/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value200/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namemaxActive/name value100/value /parameter parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/ecpa?autoReconnect=true/value /parameter /ResourceParams Logger className=org.apache.catalina.logger.FileLogger prefix=DBlog. suffix=.txt timestamp