HOW DOES TOMCAT JNDI CONNECTION POOLING WORKS
Hi all, My questing is derived from the sample code given at : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how to.html#Database%20Connection%20Pool%20(DBCP)%20Configurations If you can see the subsection 4(i.e. testcode) of section MySQL DBCP Example, to get a connection following code is used: *** Context ctx = new InitialContext(); if(ctx == null ) throw new Exception(Boom - No Context); DataSource ds = (DataSource)ctx.lookup( java:comp/env/jdbc/TestDB); if (ds != null) { Connection conn = ds.getConnection(); *** I guess by doing this a connection is obtained FROM THE POOL providing that a connection is free in the pool. I have got two questions regarding this- Q 1. Does tomcat really looks into the pool to get me a connection? or it just creates a newone? I am asking this question because I am seeing(using eclipse debugger) two connection opened at the same time even after defining maxActive=1 maxIdle=1 in my application'c context Q 2. once your database operation is done you free the connection using conn.close(); by doing this are we pushing the connection back into pool? if not then how is pool maintained? Any help is appreciated --RahulJoshi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HOW DOES TOMCAT JNDI CONNECTION POOLING WORKS
1. Does tomcat really look into the pool? Yes. The pool code is really the commons DBCP project code refactored slightly to avoid collisions with the real DBCP project code. 2. on conn.close(), are we really pushing the connection back into the pool? Yes. Sorry I can't help you on the Eclipse debugger question since I don't use it. It may be an artifact of the debugger or maybe DBCP's code. You might find the DBCP project documentation helpful in answering these questions though. --David rahul wrote: Hi all, My questing is derived from the sample code given at : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how to.html#Database%20Connection%20Pool%20(DBCP)%20Configurations If you can see the subsection 4(i.e. testcode) of section MySQL DBCP Example, to get a connection following code is used: *** Context ctx = new InitialContext(); if(ctx == null ) throw new Exception(Boom - No Context); DataSource ds = (DataSource)ctx.lookup( java:comp/env/jdbc/TestDB); if (ds != null) { Connection conn = ds.getConnection(); *** I guess by doing this a connection is obtained FROM THE POOL providing that a connection is free in the pool. I have got two questions regarding this- Q 1. Does tomcat really looks into the pool to get me a connection? or it just creates a newone? I am asking this question because I am seeing(using eclipse debugger) two connection opened at the same time even after defining maxActive=1 maxIdle=1 in my application'c context Q 2. once your database operation is done you free the connection using conn.close(); by doing this are we pushing the connection back into pool? if not then how is pool maintained? Any help is appreciated --RahulJoshi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- === David Smith Network Operations Supervisor Department of Entomology College of Agriculture Life Sciences Cornell University 2132 Comstock Hall Ithaca, NY 14853 Phone: 607.255.9571 Fax: 607.255.0939 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat DB Connection Pooling
Hi I'm having a problem reclaiming connections in my database connection pool. I'm using the standard db conn pooling with Tomcat 5.5.9 with MySQL. I release the connection as well as close the PreparedStatement in the code after use. However, I still get errors with logEnabled set to true saying that the connection was not released. I tried the same code using a simple Statement object instead of a PreparedStatement and DID NOT see the errors. The SQL I'm running in an update, i.e. Insert statement. Are there any issues reclaiming connections from a PreparedStatement? Thanks, Dhiren
RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI and Connection Pooling?
Hi Allistair, I just got the basic JNDI datasource working for MS SQL Server with Tomcat 5.5. I tried using the ConnectionPoolDataSource instead of the standard DataSource but I cannot get this working. Not sure whether I need to replace the res-typejavax.sql.DataSource/res-type with something else in the web.xml file. I changed the driverclass name from the standard datasource class of com.microsoft.jdbc.sqlserver.SQLServerDriver - used with standard datasource to the com.microsoft.jdbcx.sqlserver.SQLServerDataSource class used by MS connection pooling in the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Also added the factory for PooledConnections - factory=com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory to the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Any ideas to get the MS Connection Pooling working, or is there no need in Tomcat 5.5 - In aother words does Tomcat 5.5 automatically used Cnnection Pooling with a datasource?? Many thanks for your help with this. Best Regards, Ian -Original Message- From: Allistair Crossley [mailto:[EMAIL PROTECTED] Sent: 23 August 2005 16:05 To: Tomcat Users List; [EMAIL PROTECTED] Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? Hi Wade, Can you perhaps resend the configuration files server.xml web.xml yourapp.xml listing of files in common/lib listing of files in yourapp/WEB-INF/lib Again? Cheers, Allistair. -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: 22 August 2005 17:58 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? --- Wylie, Ian [EMAIL PROTECTED] wrote: Allistair, My apologies for taking much longer than usual to get back to you but I had to finish some Java code that allowed us to upgrade our portal to PlumTree version 5. To clarify and answer your points below. 1) I have opted not to have a context.xml file in the META-INF directory but I am using the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file instead. 2) I have ensured that the 3 MS JAR files for the JDBC connection exist only in TOMCAT_HOME/common/lib and not in my webapp lib. 3) I have changed the java code to use a simple 'DataSource' instead of a 'ConnectionPoolDataSource' connection. See Java code snippet below :- Unfortunately I still get the error below :- ERROR - NamingException - Config error with JNDI and datasource.javax.naming.NamingException: Cannot create resource instance ERROR com.webconnex.cognos.PORT.OMTLreport : Cannot create resource instance I have attached my web.xml and TOMCAT_HOME/conf/Catalina/localhost/webappname.xml files for your perusal. I am of yet no further forward in solving my problem. Any further insight would be appreciated, as Tomcat 5 allows me to do quite a few things better, not least of which is debugging!! Java Code snippet :- = logger.debug(Before InitialContext.) ; InitialContext ctx = new InitialContext(); if (ctx == null) { log(ERROR initialising InitialContext.) ; logger.error(ERROR initialising InitialContext.) ; } log(Before Context.) ; ds = (DataSource) ctx.lookup(java:comp/env/jdbc/UKportalPool); log(Before initialising DataSource.) ; if(ds != null) { con = ds.getConnection(); if (con != null) { if ((pType != null) (!pType.equals())) { userDetails = new pfUsersBean(pType, posName, typeCD, firstLineProduct); userSessionDetails = new pfUserSessionBean(); userDetails.getPrefix(con, userDetails); // See if User is in database //userDetails.getPrefix(pCon, userDetails); // See if User is in database ptpResponse.setSettingValue(SettingType.Portlet, SalesCubePrefix, userDetails.getSalesCubePrefix() ) ; ptpResponse.setSettingValue(SettingType.Portlet, description, userDetails.getGeographyID() ) ; ptpResponse.setSettingValue(SettingType.Portlet, TMTLdescription, userDetails.getGeographyID() ) ; ptpResponse.setSettingValue(SettingType.Portlet, MSOdescription, userDetails.getGeographyID() ) ; } } else { log(ERROR - DB Connection returned was null in PortletHelper
RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server using JNDI and Connection Pooling?
Hey Ian, Great that you got that working in the end. Did you find out what caused the issues? I'm not convinced you need to use the ConnectionPoolDataSource, since that's what DBCP is doing for you (I think - please someone correct me if I am wrong). You could try using javax.sql.ConnectionPoolDataSource in your res-type and in the JNDI configuration, but I am not sure if DBCP will allow you to do that. Have a go. I just use the DataSource implementation and we've had great success and performance with it. Cheers, Allistair. -Original Message- From: Wylie, Ian [mailto:[EMAIL PROTECTED] Sent: 24 August 2005 12:33 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server using JNDI and Connection Pooling? Hi Allistair, I just got the basic JNDI datasource working for MS SQL Server with Tomcat 5.5. I tried using the ConnectionPoolDataSource instead of the standard DataSource but I cannot get this working. Not sure whether I need to replace the res-typejavax.sql.DataSource/res-type with something else in the web.xml file. I changed the driverclass name from the standard datasource class of com.microsoft.jdbc.sqlserver.SQLServerDriver - used with standard datasource to the com.microsoft.jdbcx.sqlserver.SQLServerDataSource class used by MS connection pooling in the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Also added the factory for PooledConnections - factory=com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFact ory to the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Any ideas to get the MS Connection Pooling working, or is there no need in Tomcat 5.5 - In aother words does Tomcat 5.5 automatically used Cnnection Pooling with a datasource?? Many thanks for your help with this. Best Regards, Ian -Original Message- From: Allistair Crossley [mailto:[EMAIL PROTECTED] Sent: 23 August 2005 16:05 To: Tomcat Users List; [EMAIL PROTECTED] Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? Hi Wade, Can you perhaps resend the configuration files server.xml web.xml yourapp.xml listing of files in common/lib listing of files in yourapp/WEB-INF/lib Again? Cheers, Allistair. -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: 22 August 2005 17:58 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? --- Wylie, Ian [EMAIL PROTECTED] wrote: Allistair, My apologies for taking much longer than usual to get back to you but I had to finish some Java code that allowed us to upgrade our portal to PlumTree version 5. To clarify and answer your points below. 1) I have opted not to have a context.xml file in the META-INF directory but I am using the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file instead. 2) I have ensured that the 3 MS JAR files for the JDBC connection exist only in TOMCAT_HOME/common/lib and not in my webapp lib. 3) I have changed the java code to use a simple 'DataSource' instead of a 'ConnectionPoolDataSource' connection. See Java code snippet below :- Unfortunately I still get the error below :- ERROR - NamingException - Config error with JNDI and datasource.javax.naming.NamingException: Cannot create resource instance ERROR com.webconnex.cognos.PORT.OMTLreport : Cannot create resource instance I have attached my web.xml and TOMCAT_HOME/conf/Catalina/localhost/webappname.xml files for your perusal. I am of yet no further forward in solving my problem. Any further insight would be appreciated, as Tomcat 5 allows me to do quite a few things better, not least of which is debugging!! Java Code snippet :- = logger.debug(Before InitialContext.) ; InitialContext ctx = new InitialContext(); if (ctx == null) { log(ERROR initialising InitialContext.) ; logger.error(ERROR initialising InitialContext.) ; } log(Before Context.) ; ds = (DataSource) ctx.lookup(java:comp/env/jdbc/UKportalPool); log(Before initialising DataSource.) ; if(ds != null) { con = ds.getConnection(); if (con != null) { if ((pType != null) (!pType.equals())) { userDetails = new pfUsersBean(pType, posName, typeCD, firstLineProduct
RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server using JNDI and Connection Pooling?
Hi again, By the way, you really ought to consider *not* using the MS drivers. jTDS at jtds.sourceforge.net is more performant. Cheers, Allistair -Original Message- From: Wylie, Ian [mailto:[EMAIL PROTECTED] Sent: 24 August 2005 12:33 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server using JNDI and Connection Pooling? Hi Allistair, I just got the basic JNDI datasource working for MS SQL Server with Tomcat 5.5. I tried using the ConnectionPoolDataSource instead of the standard DataSource but I cannot get this working. Not sure whether I need to replace the res-typejavax.sql.DataSource/res-type with something else in the web.xml file. I changed the driverclass name from the standard datasource class of com.microsoft.jdbc.sqlserver.SQLServerDriver - used with standard datasource to the com.microsoft.jdbcx.sqlserver.SQLServerDataSource class used by MS connection pooling in the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Also added the factory for PooledConnections - factory=com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFact ory to the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Any ideas to get the MS Connection Pooling working, or is there no need in Tomcat 5.5 - In aother words does Tomcat 5.5 automatically used Cnnection Pooling with a datasource?? Many thanks for your help with this. Best Regards, Ian -Original Message- From: Allistair Crossley [mailto:[EMAIL PROTECTED] Sent: 23 August 2005 16:05 To: Tomcat Users List; [EMAIL PROTECTED] Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? Hi Wade, Can you perhaps resend the configuration files server.xml web.xml yourapp.xml listing of files in common/lib listing of files in yourapp/WEB-INF/lib Again? Cheers, Allistair. -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: 22 August 2005 17:58 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? --- Wylie, Ian [EMAIL PROTECTED] wrote: Allistair, My apologies for taking much longer than usual to get back to you but I had to finish some Java code that allowed us to upgrade our portal to PlumTree version 5. To clarify and answer your points below. 1) I have opted not to have a context.xml file in the META-INF directory but I am using the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file instead. 2) I have ensured that the 3 MS JAR files for the JDBC connection exist only in TOMCAT_HOME/common/lib and not in my webapp lib. 3) I have changed the java code to use a simple 'DataSource' instead of a 'ConnectionPoolDataSource' connection. See Java code snippet below :- Unfortunately I still get the error below :- ERROR - NamingException - Config error with JNDI and datasource.javax.naming.NamingException: Cannot create resource instance ERROR com.webconnex.cognos.PORT.OMTLreport : Cannot create resource instance I have attached my web.xml and TOMCAT_HOME/conf/Catalina/localhost/webappname.xml files for your perusal. I am of yet no further forward in solving my problem. Any further insight would be appreciated, as Tomcat 5 allows me to do quite a few things better, not least of which is debugging!! Java Code snippet :- = logger.debug(Before InitialContext.) ; InitialContext ctx = new InitialContext(); if (ctx == null) { log(ERROR initialising InitialContext.) ; logger.error(ERROR initialising InitialContext.) ; } log(Before Context.) ; ds = (DataSource) ctx.lookup(java:comp/env/jdbc/UKportalPool); log(Before initialising DataSource.) ; if(ds != null) { con = ds.getConnection(); if (con != null) { if ((pType != null) (!pType.equals())) { userDetails = new pfUsersBean(pType, posName, typeCD, firstLineProduct); userSessionDetails = new pfUserSessionBean(); userDetails.getPrefix(con, userDetails); // See if User is in database //userDetails.getPrefix(pCon, userDetails); // See if User is in database ptpResponse.setSettingValue(SettingType.Portlet, SalesCubePrefix
RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI and Connection Pooling?
Hi Allistair, The problem was that I had duplicated the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml entry in server.xml. So I removed the context element from server.xml. Then, the basic datasource JNDI started working. I will investigate the change you suggested for Connection Pooling as well as have a look at jTDS. I will report back after further investigations. It is great to be able to use Tomcat 5.5 with the JVM 1.5. I have just downloaded and installed Eclipse 3.1 which can compile using the JVM 1.5 - as one of my other tasks currently is to call a .NET web service from Java. I am hoping to get this working using Apache SOAP. Many thanks for your help with this. Best Regards, Ian -Original Message- From: Allistair Crossley [mailto:[EMAIL PROTECTED] Sent: 24 August 2005 12:42 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server using JNDI and Connection Pooling? Hi again, By the way, you really ought to consider *not* using the MS drivers. jTDS at jtds.sourceforge.net is more performant. Cheers, Allistair -Original Message- From: Wylie, Ian [mailto:[EMAIL PROTECTED] Sent: 24 August 2005 12:33 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server using JNDI and Connection Pooling? Hi Allistair, I just got the basic JNDI datasource working for MS SQL Server with Tomcat 5.5. I tried using the ConnectionPoolDataSource instead of the standard DataSource but I cannot get this working. Not sure whether I need to replace the res-typejavax.sql.DataSource/res-type with something else in the web.xml file. I changed the driverclass name from the standard datasource class of com.microsoft.jdbc.sqlserver.SQLServerDriver - used with standard datasource to the com.microsoft.jdbcx.sqlserver.SQLServerDataSource class used by MS connection pooling in the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Also added the factory for PooledConnections - factory=com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFact ory to the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file. Any ideas to get the MS Connection Pooling working, or is there no need in Tomcat 5.5 - In aother words does Tomcat 5.5 automatically used Cnnection Pooling with a datasource?? Many thanks for your help with this. Best Regards, Ian -Original Message- From: Allistair Crossley [mailto:[EMAIL PROTECTED] Sent: 23 August 2005 16:05 To: Tomcat Users List; [EMAIL PROTECTED] Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? Hi Wade, Can you perhaps resend the configuration files server.xml web.xml yourapp.xml listing of files in common/lib listing of files in yourapp/WEB-INF/lib Again? Cheers, Allistair. -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: 22 August 2005 17:58 To: Tomcat Users List Subject: RE: Has anyone used Tomcat 5.5.9 connecting to MS SQL Server usin g JNDI? --- Wylie, Ian [EMAIL PROTECTED] wrote: Allistair, My apologies for taking much longer than usual to get back to you but I had to finish some Java code that allowed us to upgrade our portal to PlumTree version 5. To clarify and answer your points below. 1) I have opted not to have a context.xml file in the META-INF directory but I am using the TOMCAT_HOME/conf/Catalina/localhost/webappname.xml file instead. 2) I have ensured that the 3 MS JAR files for the JDBC connection exist only in TOMCAT_HOME/common/lib and not in my webapp lib. 3) I have changed the java code to use a simple 'DataSource' instead of a 'ConnectionPoolDataSource' connection. See Java code snippet below :- Unfortunately I still get the error below :- ERROR - NamingException - Config error with JNDI and datasource.javax.naming.NamingException: Cannot create resource instance ERROR com.webconnex.cognos.PORT.OMTLreport : Cannot create resource instance I have attached my web.xml and TOMCAT_HOME/conf/Catalina/localhost/webappname.xml files for your perusal. I am of yet no further forward in solving my problem. Any further insight would be appreciated, as Tomcat 5 allows me to do quite a few things better, not least of which is debugging!! Java Code snippet :- = logger.debug(Before InitialContext.) ; InitialContext ctx = new InitialContext(); if (ctx == null) { log(ERROR initialising InitialContext.) ; logger.error(ERROR initialising InitialContext.) ; } log(Before Context.) ; ds
RE: Tomcat application won't start with MySQL Connection Pooling
Please note the following for the path attribute in the Tomcat 5.5 doc for Context: The value of this field must not be set except when statically defining a Context in server.xml, as it will be infered [sic] from the filenames used for either the .xml context file or the docBase. Also, examine the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory (usually conf/Catalina/localhost/), and remove any .xml files that might have been automatically created previously for your application and restart Tomcat. Thanks for pointing this out. I have made the changes and still I have the problem of my application failing to start. However it looks like this is not a problem with Tomcat but instead a problem with Spring. My application is a Spring MVC application, and I am trying to get the MySQL DBCP DataSource via JNDI. It appears that this is where the problem lies, since I can remove this part of the Spring configuration and the application starts fine when Tomcat is started. Also I can run the test JSP and access the MySQL DBCP DataSource with no errors. So it seems that I have the correct MySQL DBCP configuration, just not the right Spring configuration for accessing it via JNDI. Thanks again for your help with this. --James __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat application won't start with MySQL Connection Pooling
From: James Adams [mailto:[EMAIL PROTECTED] Subject: RE: Tomcat application won't start with MySQL Connection Pooling I have now created a context.xml according to the example in the Tomcat 5.5 documentation and this time I've placed it my application's META-INF directory in the WAR --- META-INF/context.xml - Context path=/ioifocus Please note the following for the path attribute in the Tomcat 5.5 doc for Context: The value of this field must not be set except when statically defining a Context in server.xml, as it will be infered [sic] from the filenames used for either the .xml context file or the docBase. Also, examine the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory (usually conf/Catalina/localhost/), and remove any .xml files that might have been automatically created previously for your application and restart Tomcat. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat application won't start with MySQL Connection Pooling
I have tried adding connection pooling for a MySQL database in Tomcat 5.5 by following the steps described [URL=http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html]here[/URL]. Now when I start Tomcat my application fails to load. The only message I can find in any of the logs is Aug 5, 2005 12:40:44 PM org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart Aug 5, 2005 12:40:44 PM org.apache.catalina.core.StandardContext start SEVERE: Context [/ioifocus] startup failed due to previous errors Where can I look for further information on what is causing the error? I'm pretty sure that I have followed the Tomcat Connection Pooling example faithfully (I added the commons libraries to Tomcat's lib directory, I modified my server.xml and web.xml as shown, etc.), and the XML I added to the server.xml appears to be valid. In any event I will include the XML which I added to Tomcat's server.xml just in case anyone can see a mistake (the following is included under the Host element which defines localhost): Context path=/ioifocus docBase=ioifocus debug=5 reloadable=true crossContext=true Logger className=org.apache.catalina.logger.FileLogger prefix=localhost_ioifocus_log. suffix=.txt timestamp=true/ Resource name=jdbc/MySqlDataSource auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/MySqlDataSource 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 -1 for no limit. See also the DBCP documentation on this and the minEvictableIdleTimeMillis configuration parameter. -- 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 username and password for database connections -- parameter nameusername/name valueadmin/value /parameter parameter namepassword/name valueadminpassword/value /parameter !-- Class name for the official MySQL Connector/J driver -- parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter !-- The JDBC connection url for connecting to the MySQL database -- parameter nameurl/name valuejdbc:mysql://localhost:3306/ioifocus/value /parameter !-- Insure that databse connections are removed and recycled if they become abandoned by a web application which doesn't close resources such as ResultSets, Statements, or Connections -- parameter nameremoveAbandoned/name valuetrue/value /parameter /ResourceParams /Context Thanks in advance for any help with this! --James __ Yahoo! Mail for Mobile Take Yahoo! Mail with you! Check email on your mobile phone. http://mobile.yahoo.com/learn/mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat application won't start with MySQL Connection Pooling
From: James Adams [mailto:[EMAIL PROTECTED] Subject: Tomcat application won't start with MySQL Connection Pooling I have tried adding connection pooling for a MySQL database in Tomcat 5.5 by following the steps described [URL=http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-data source-examples-howto.html]here[/URL]. I'm curious: why are you using the documentation for an older level to configure the current version? Things have changed in this area (among others) between 5.0 and 5.5. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat application won't start with MySQL Connection Pooling
I'm curious: why are you using the documentation for an older level to configure the current version? Things have changed in this area (among others) between 5.0 and 5.5. You bring up a very good point, thanks for spotting that for me. I have now created a context.xml according to the example in the Tomcat 5.5 documentation and this time I've placed it my application's META-INF directory in the WAR (since it was pointed out to me that this approach is preferable to modifying the server.xml file). Unfortunately I still get the same errors as before, with no more information in the log files other than the cryptic SEVERE: Error listenerStart message. Below are the contents of my META-INF/context.xml file. Does anything look amiss now? Perhaps I need to enclose this Context entry with a Server, Service, or Host entry? --- META-INF/context.xml - Context path=/ioifocus docBase=ioifocus debug=5 reloadable=true crossContext=true Resource name=jdbc/MySqlDataSource auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=admin password=XXX driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/ioifocus removeAbandoned=true / /Context Thanks in advance for any further help/insight... --James __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat 5.5.9 connection pooling
Hi! I am using Tomcat 5.5.9 and I have established a DataSource for database connection pooling where I can get connections from. But when I try to close the connection via myConnection.close(), always an exception is thrown. Is it right to close the connection this way or do I have to return the connection to the pool in another way? Peter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5.9 connection pooling
Can you attach the exception thrown ? Viorel Dragomir . .. --- - Original Message - From: [EMAIL PROTECTED] To: tomcat-user@jakarta.apache.org Sent: Monday, July 18, 2005 13:38 Subject: Tomcat 5.5.9 connection pooling Hi! I am using Tomcat 5.5.9 and I have established a DataSource for database connection pooling where I can get connections from. But when I try to close the connection via myConnection.close(), always an exception is thrown. Is it right to close the connection this way or do I have to return the connection to the pool in another way? Peter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5.9 connection pooling
Can you please write what exception do you get when you try to close the database connection? - Original Message - From: [EMAIL PROTECTED] To: tomcat-user@jakarta.apache.org Sent: Monday, July 18, 2005 4:38 PM Subject: Tomcat 5.5.9 connection pooling Hi! I am using Tomcat 5.5.9 and I have established a DataSource for database connection pooling where I can get connections from. But when I try to close the connection via myConnection.close(), always an exception is thrown. Is it right to close the connection this way or do I have to return the connection to the pool in another way? Peter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: Tomcat 5.5.9 connection pooling
Here is the exception that is thrown. As you can see my connection seems to be already closed. But why? Can this be configured somewhere? -Ursprüngliche Nachricht- Von: Viorel Dragomir [mailto:[EMAIL PROTECTED] Gesendet: Montag, 18. Juli 2005 14:46 An: Tomcat Users List Betreff: Re: Tomcat 5.5.9 connection pooling Can you attach the exception thrown ? Viorel Dragomir . .. --- - Original Message - From: [EMAIL PROTECTED] To: tomcat-user@jakarta.apache.org Sent: Monday, July 18, 2005 13:38 Subject: Tomcat 5.5.9 connection pooling Hi! I am using Tomcat 5.5.9 and I have established a DataSource for database connection pooling where I can get connections from. But when I try to close the connection via myConnection.close(), always an exception is thrown. Is it right to close the connection this way or do I have to return the connection to the pool in another way? Peter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] java.sql.SQLException: Connection is closed. at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:174) at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:179) at com.materna.buc.buildmanager.database.impl.BMDatabaseHandlerImpl.getUserList(Unknown Source) at com.materna.buc.buildmanager.actions.CreateLoginAction.execute(Unknown Source) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at com.materna.buc.buildmanager.controller.BMRequestProcessor.processPreprocess(Unknown Source) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:184) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:693) at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:660) at org.apache.struts.taglib.logic.ForwardTag.doForward(ForwardTag.java:121) at org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.java:105) at org.apache.jsp.index_jsp._jspx_meth_logic_forward_0(org.apache.jsp.index_jsp:88) at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:61) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252
Re: AW: Tomcat 5.5.9 connection pooling
Hi Peter, i've had this problem in a project long ago. I left the company befor i solved this, but meanwhile i am quite sure this was not a problem of Tomcat, but of using ResultSet wrong. Maybe this is your problem too. ResultSet is a connection to the database- if you iterate over ResultSet when the connection has allready be closed you get this error. Check for this errors: db.getConnection(); ResultSet rs = Statement... db.closeConnection(): while(rs.hasNext()) Hope this helps, Chris [EMAIL PROTECTED] wrote: Here is the exception that is thrown. As you can see my connection seems to be already closed. But why? Can this be configured somewhere? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat Connection Pooling - Future of?
Greetings, I am a student at the University of Delaware looking to do research on connection pooling. Currently I am analyzing the feasability of optimizing connection pooling. My hypothesis is that using a statistical analysis of the usage history to create a prediction of usage levels in the future, and adjusting the connection pool's settings based on usage level predictions will increase the throughput and decrease system requirements for websites with trends in user levels. does anyone know of any research that has been done / currently being done on this topic? Sincerely, Peter K. Steijn
Tomcat5.0 Database Connection Pooling Configuration
Hi there, Have a question on dbcp settings. I'd done the settings by configuring the server.xml and the web.xml of my application and it works fine. But since i need to install multiple application on the same Tomcat server, i'll need to place different context tag in the server.xml for each application to enable the datasource for each of my apps. Since my apps are all connecting to a same database server, is there any configuration method that allows me to setup once in server.xml (such as setting a 'common context') and let my web.xml to handle the rest? Thanx. Regards, F.S.
Re: Tomcat5.0 Database Connection Pooling Configuration
you can define resources for all of a host's contexts by using a GlobalNamingResources element see here for more info: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/globalresources.html On 7/13/05, Foo Shyn [EMAIL PROTECTED] wrote: Hi there, Have a question on dbcp settings. I'd done the settings by configuring the server.xml and the web.xml of my application and it works fine. But since i need to install multiple application on the same Tomcat server, i'll need to place different context tag in the server.xml for each application to enable the datasource for each of my apps. Since my apps are all connecting to a same database server, is there any configuration method that allows me to setup once in server.xml (such as setting a 'common context') and let my web.xml to handle the rest? Thanx. Regards, F.S. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
connection pooling oracle
I am attempting to set up connection pooling in tomcat 5.0.28 using oracle 10g. I am able to successfully use org.apache.commons.dbcp.BasicDataSourceFactory as long as my rs.executeQuery() is not cast to OracleResultSet. I have seen a few threads on this topic but I can't seem to find an implementation that I can actually get to work. Does anyone have any helpful info that can guide me in the right direction? Thanks
Re: connection pooling oracle
Brian, What is it that you're looking to accomplish with that cast? It makes it hard for others to respond with suggestions when they don't know what your criteria are. Also, how does it fail when you try it (ie ClassCastException)? Personally, I haven't run into any issues, but I just stick with the generic result set. Give a few more details so that people can understand your issue. Cheers, PST On 6/6/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am attempting to set up connection pooling in tomcat 5.0.28 using oracle 10g. I am able to successfully use org.apache.commons.dbcp.BasicDataSourceFactory as long as my rs.executeQuery() is not cast to OracleResultSet. I have seen a few threads on this topic but I can't seem to find an implementation that I can actually get to work. Does anyone have any helpful info that can guide me in the right direction? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
Hi I also struggled for the Tomcat Connection Pooling problem for one week and i got the solution. write the follwing code snippets in respective files: -web.xml-- resource-ref res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref --server.xml--- write the following code in server.xml in Context tag Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/TestDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valuewriter the driver class which you are using/value /parameter parameter nameurl/name valuewrite the url here/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter namemaxWait/name value-1/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter /ResourceParams and also add the following code in the file in which you are using database code and import javax.naming.* and javax.sql.* packages.. Context ctx=new InitialContext(); DataSource ds=(DataSource)ctx.lookup(java:/comp/env/jdbc/TestDB); Connection con=ds.getConnection(); Statement st = con.createStatement(); Make sure that commons-dbcp,commons-collections and commons-pool files in common/lib directory. I hope that this mail will help you in finding out the solution. regards, -Ajay Kumar On Apr 10, 2005 1:20 AM, Krishnakant Mane [EMAIL PROTECTED] wrote: thanks a lot doug, if I have any problem I will trouble again. just a couple of questions. there were two parameters in the email you sent the other day. I did not get the meaning of those parameters stating that active connections should be 100 and the other with 30 as the value. what is the difference between max active and inactive connections? and just a curious question, is tomcat really used on heavy duty commertial websites? thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Ajay - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
connection pooling with JTOpen Toolbox_tomcat 5.5.7
Using: tomcat 5.5.7, JTOpen 4.7 JDBC Driver for AS/400 DB2 The DBAdmin of the company I work for ends the subsystems at night time for the backup, so the connection dies during that time and when I try to reconnect to application server via my webapp in the morning, it throws me exception saying that the connection does not exist: WARN http-8080-Processor22 net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: -9, SQLState: 08003 ERROR http-8080-Processor22 net.sf.hibernate.util.JDBCExceptionReporter - The connection does not exist. However, after I try it couple of times I am able to connect, probably Tomcat re-establishes the connection to AS/400, so I was wondering if there was any parameter such as autoreconnect (such as in mysql) that can be provided in server.xml file, which will automatically reconnect in the first try instead of having to try if few times. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
hello Mr. Ajay Kumar, thanks a lot. I am using tomcat 5.0.25 and I have the context file in the conf/Catalina/localhost directory. in that file where should I put the code u provided in server.xml after the tag is over or before the tag is closed? thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
thanks a lot doug, if I have any problem I will trouble again. just a couple of questions. there were two parameters in the email you sent the other day. I did not get the meaning of those parameters stating that active connections should be 100 and the other with 30 as the value. what is the difference between max active and inactive connections? and just a curious question, is tomcat really used on heavy duty commertial websites? thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
thanks doug. I got my application right. only one problem remains. where do I initialise the connection. and what should I do in the init method of the servlet. or is it that I wont need to use the init method at all? thanks again Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
Since the Conn method is static you do not need to initialize it. The DBUtil class actually handles all that for you. Just send your query string to the method there and get back the instance of the data results class. No init needed. Doug - Original Message - From: Krishnakant Mane [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Friday, April 08, 2005 5:06 AM Subject: Re: still not clear with connection pooling in tomcat thanks doug. I got my application right. only one problem remains. where do I initialise the connection. and what should I do in the init method of the servlet. or is it that I wont need to use the init method at all? thanks again Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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: still not clear with connection pooling in tomcat
never mind doug, in fact it seams that your asking questions reflects nothing but professionalism and perfection. that's the way to do it. by the way the relation to databases is one to one with web apps. one web app is going to refer to only one database. so that is the way it is going to be. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
No problem. With a one to one, set up the dataresource in the context element of the app. Place this after your context element. You will need to either declare one in the server.xml, in your app war file or create a file yourapp.xml and place it in the Tomcat dir: tomcat_home/conf/Catalina/localhost or the matching host for the app. Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/TestDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name valuejavauser/value /parameter parameter namepassword/name valuejavadude/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/javatest?autoReconnect=true/value /parameter /ResourceParams Make sure the resource name= resourceParams name= and the name called out in the class I sent in the last email all match including case. Set the url to match the database name in place of javatest. And use the user and password you created for the database. I create a user in the database and limit the rights to only the one databse and with limited rights. Add this to the web.xml for the app: resource-ref descriptionDB Connection/description res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Again match the res-ref-name to the name used above for the resource. And that should get things talking if you have set up all the database and users. The above examples are from: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html Good luck. - Original Message - From: Krishnakant Mane [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Wednesday, April 06, 2005 8:08 AM Subject: Re: still not clear with connection pooling in tomcat never mind doug, in fact it seams that your asking questions reflects nothing but professionalism and perfection. that's the way to do it. by the way the relation to databases is one to one with web apps. one web app is going to refer to only one database. so that is the way it is going to be. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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: still not clear with connection pooling in tomcat
hello doug, I will be using this tomcat server for many web applications. and yes the mysql instance will be the same. I just run one mysqld instance for my server. there will be different databases and different web applications. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
: * UL * LIResultSet doesn't necessarily have all the data; * reconnection to database occurs as you ask for * later rows. * LIThis class stores results as strings, in arrays. * LIThis class includes DatabaseMetaData (database product * name and version) and ResultSetMetaData * (the column names). * LIThis class has a toHTMLTable method that turns * the results into a long string corresponding to * an HTML table. * /UL * P * Taken from Core Servlets and JavaServer Pages * from Prentice Hall and Sun Microsystems Press, * http://www.coreservlets.com/. * copy; 2000 Marty Hall; may be freely used or adapted. */ public class DBResults { private Connection connection; private String productName; private String productVersion; private int columnCount; private String[] columnNames; private Vector queryResults; String[] rowData; public DBResults(Connection connection, String productName, String productVersion, int columnCount, String[] columnNames) { this.connection = connection; this.productName = productName; this.productVersion = productVersion; this.columnCount = columnCount; this.columnNames = columnNames; rowData = new String[columnCount]; queryResults = new Vector(); } public void addRow(String[] row) { queryResults.addElement(row); } public int getColumnCount() { return(columnCount); } public String[] getColumnNames() { return(columnNames); } public Connection getConnection() { return(connection); } public String getProductName() { return(productName); } public String getProductVersion() { return(productVersion); } public String[] getRow(int index) { return((String[])queryResults.elementAt(index)); } public int getRowCount() { return(queryResults.size()); } /** returns the row and column equivelent from the DBResults */ public String getData(int r, int c){ return(((String[])queryResults.elementAt(r))[c]); } /** returns the row and column equivelent from the DBResults or empty string if null or out of bounds*/ public String getDataP(int r, int c){ try{ return(((String[])queryResults.elementAt(r))[c]); }catch(ArrayIndexOutOfBoundsException e){return ;} } /** Output the results as an HTML table, with * the column names as headings and the rest of * the results filling regular data cells. */ public String toHTMLTable(String headingColor) { StringBuffer buffer = new StringBuffer(TABLE BORDER=1\n); if (headingColor != null) { buffer.append( TR BGCOLOR=\ + headingColor + \\n ); } else { buffer.append( TR\n ); } for(int col=0; colgetColumnCount(); col++) { buffer.append(TH + columnNames[col]); } for(int row=0; rowgetRowCount(); row++) { buffer.append(\n TR\n ); String[] rowData = getRow(row); for(int col=0; colgetColumnCount(); col++) { buffer.append(TD + rowData[col]); } } buffer.append(\n/TABLE); return(buffer.toString()); } } This has one drawback, you cannot take advantage of an updatable recordset. Any changes must be written back to the database with an update. - Original Message - From: Krishnakant Mane [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, April 05, 2005 3:37 AM Subject: Re: still not clear with connection pooling in tomcat hello doug, I will be using this tomcat server for many web applications. and yes the mysql instance will be the same. I just run one mysqld instance for my server. there will be different databases and different web applications. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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: still not clear with connection pooling in tomcat
hello doug, I am sending the following details on the questions you asked. and thanks for your help. I am using mysql as the database back-end and tomcat version 5. I have the mysql jdbc the latest stable version. and the server is right now going to support a single application but I plan to serve more apps in a few days. Please help me with the info I need. I will be obliged if u could give an example. I am again thankfull to you as you exactly understood my problem and the confusion I faced with the articles on the net. Please provide a servlet based example not a jsp one. thanks again Krishnakant Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
Because there are different versions, and the setup is different, I need exact version of Tomcat. What was the file name you downloaded? Was it a 5.0.xx or 5.5.x for they are different? Doug - Original Message - From: Krishnakant Mane [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Monday, April 04, 2005 2:16 AM Subject: Re: still not clear with connection pooling in tomcat hello doug, I am sending the following details on the questions you asked. and thanks for your help. I am using mysql as the database back-end and tomcat version 5. I have the mysql jdbc the latest stable version. and the server is right now going to support a single application but I plan to serve more apps in a few days. Please help me with the info I need. I will be obliged if u could give an example. I am again thankfull to you as you exactly understood my problem and the confusion I faced with the articles on the net. Please provide a servlet based example not a jsp one. thanks again Krishnakant Send instant messages to your online friends http://uk.messenger.yahoo.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: still not clear with connection pooling in tomcat
doug, thanks again for ur response. Well it is not 5.5. It is 5.0.xx Thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
Will more than one of the apps be using the same database? That is the same tables and data? Even if they are using the same database engine IE MySQL on the server, will it be the same database instance? Doug - Original Message - From: Krishnakant Mane [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Monday, April 04, 2005 7:25 AM Subject: Re: still not clear with connection pooling in tomcat doug, thanks again for ur response. Well it is not 5.5. It is 5.0.xx Thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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: connection pooling basic help please
Krishnakant Mane wrote: hello, I refered to the docs in tomcat 5 for connection pooling. the document is pritty comprehencive and I understood the server.xml part of it. but now I want to know how exactly can I use a connection from the pool in my servlet. the example in tomcat documentation is on a jsp based applicatio. but I don't understand how I use a pooled connection in a servlet. You use a pooled connection in a simillar manner to a driver managed connection, except that you look up a resource (JNDI in this case). In your servlet just look up the resource. should I initialise the connection in the Init method? how and when should I close the connection? You should close the connection immediately when you are done with it. Best not to pass references of them around. You would close them as a you would in a driver managed connection, that is Connection.close() ; and wat entries in the web.xml file will effect connection pooling? Please help it is really urgent. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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: still not clear with connection pooling in tomcat
hello all, Thanks for your help on this issue. however I still can't get my problem solved. 10 different articles give 10 different solutions. however my problem is simple. I have a streight forward question. I want to implement connection pooling in the tomcat 5 web container and I have the jakarta commons packages as well as the mysql jdbc jar file in the proper place. I found one good example in the tomcat 5 docs, but it talks about an example in jsp. I exclusively use servlets and I want to know how I use connection pooling in the servlet. where do I use the Initial context and where do I initialise it? where will the datasource come into question? and how I use the connection object with the datasource? all this I want to know in context of a servlet not jsp. Please help me and please no more references to other documents I have read enough of those articles and I am getting more and more confused. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: still not clear with connection pooling in tomcat
In the beginning a programmer created ... Seriously it goes like this: To use pooling in Tomcat you can forget a lot of what is in the java api as Tomcat uses this to provide pooling for you. Steps to take: 1.Determine the database you are going to use. 2.Get the JDBC drivers for that database and put them in common/lib 3.Determine if the database pool is going to serve one application or many. 4.If many, set up a Global Resource in server.xml 5.If many, add a resource link to the context for each app 4a. If one, set up a resource in the context. 5a.If one, do nothing. 6.Create a class that makes a call to retrieve the resource from the context. 7.From that resource a datasource is received. 8.Ask for a connection from the datasource. 9.Tomcat will give you a connection from the pool it creates when it sets up the resource. 10.Use this connection as you would one from a datamanager. 11.Close the connection when you are done and Tomcat will put it back in the pool. 12.DO NOT call DataManager as you will bypass the connection pool. Now after reading this, to help us give you more help please fill in the details above on 1,2 and 3. Give us the exact version of Tomcat. And OS version. Doug - Original Message - From: Krishnakant Mane [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Sunday, April 03, 2005 8:47 AM Subject: RE: still not clear with connection pooling in tomcat hello all, Thanks for your help on this issue. however I still can't get my problem solved. 10 different articles give 10 different solutions. however my problem is simple. I have a streight forward question. I want to implement connection pooling in the tomcat 5 web container and I have the jakarta commons packages as well as the mysql jdbc jar file in the proper place. I found one good example in the tomcat 5 docs, but it talks about an example in jsp. I exclusively use servlets and I want to know how I use connection pooling in the servlet. where do I use the Initial context and where do I initialise it? where will the datasource come into question? and how I use the connection object with the datasource? all this I want to know in context of a servlet not jsp. Please help me and please no more references to other documents I have read enough of those articles and I am getting more and more confused. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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]
connection pooling basic help please
hello, I refered to the docs in tomcat 5 for connection pooling. the document is pritty comprehencive and I understood the server.xml part of it. but now I want to know how exactly can I use a connection from the pool in my servlet. the example in tomcat documentation is on a jsp based applicatio. but I don't understand how I use a pooled connection in a servlet. should I initialise the connection in the Init method? how and when should I close the connection? and wat entries in the web.xml file will effect connection pooling? Please help it is really urgent. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connection pooling basic help please
On Sat, Apr 02, 2005 at 08:21:24PM +0100, Krishnakant Mane wrote: : the example in tomcat documentation is on a jsp based : applicatio. but I don't understand how I use a pooled : connection in a servlet. : [snip] : should I initialise the connection in the Init method? : how and when should I close the connection? 1/ please post a *new* message when writing to the list. Replying to an old (unrelated) message confuses thread-aware mailers, which makes your question harder to find (and thus answer). 2/ I don't have the JSP sample in front of me, but there should be plenty of examples of using a DataSource out on the web. A little Googling should turn them up. The short version is: - perform a JNDI lookup to find the DataSource - pull a Connection from that data source - use the Connection to talk with a databse - call close() on that connection You should hold on to the Connection for as short a period of time as possible. This is easier to manage if all of the database calls are done from a particular set of objects (a data layer). Having all of your components do the JNDI lookup, etc can get messy and tough to maintain. Isolate all of your data calls to a separate object (or set of objects). You could initialize these objects in a ServletContextListener and either store them under Application scope or in a singleton such that they would be globally available. -QM -- software -- http://www.brandxdev.net/ tech news -- http://www.RoarNetworX.com/ code scan -- http://www.JxRef.org/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
still not clear with connection pooling in tomcat
hello all, I am still a bit confused on the pooling issue in tomcat. I will be very happy if some one could explain connection pooling with reference to my problems listed below. 1. there are the jakarta commons libraries like the dbcp etc in the catalina/common/lib directory. how do I take advantage of these libraries to use pooled connections? Wat I mean is that I found some resources on google which did explain connection pooling but those articles tryed to use some other methods. I know how to setup the tags in server.xml but don't know what to do in a servlet and where to do it after the commons jars are made available. 2. there were two tags in server.xml out of which one is for the maximum pool of connections eg 100 500 etc. and the other tag is related to innactive connections. can some one explain? I am confused with these two tags. 3. right now I am not using connection pooling and I am opening connections in the init methods of my servlets. what changes should I make in my servlets after a connection pool is established? 4. where should I initialise the context and lookup the connection from the data source? I will be happy if some one gives an example of just the code snippad of using a pooled connection in a servlet. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: still not clear with connection pooling in tomcat
everything you need is here: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html -Original Message- From: Krishnakant Mane [mailto:[EMAIL PROTECTED] Sent: Sunday, April 03, 2005 7:05 AM To: tomcat-user@jakarta.apache.org Subject: still not clear with connection pooling in tomcat hello all, I am still a bit confused on the pooling issue in tomcat. I will be very happy if some one could explain connection pooling with reference to my problems listed below. 1. there are the jakarta commons libraries like the dbcp etc in the catalina/common/lib directory. how do I take advantage of these libraries to use pooled connections? Wat I mean is that I found some resources on google which did explain connection pooling but those articles tryed to use some other methods. I know how to setup the tags in server.xml but don't know what to do in a servlet and where to do it after the commons jars are made available. 2. there were two tags in server.xml out of which one is for the maximum pool of connections eg 100 500 etc. and the other tag is related to innactive connections. can some one explain? I am confused with these two tags. 3. right now I am not using connection pooling and I am opening connections in the init methods of my servlets. what changes should I make in my servlets after a connection pool is established? 4. where should I initialise the context and lookup the connection from the data source? I will be happy if some one gives an example of just the code snippad of using a pooled connection in a servlet. thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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: connection pooling confusion help needed
Hi, Please follow the directions by user rmorriso on the following link. It should work fine. http://forums.devshed.com/archive/t-120081 On Fri, 25 Mar 2005 19:11:15 + (GMT), Krishnakant Mane [EMAIL PROTECTED] wrote: hello all, im going to put a web application in java servlets with tomcat 5 on a production ready server for real time use. I am thinking of using connection pooling but I am a bit confused. I have initialised all my connections in the servlet's init method and closed them in distroy method. so these connections are not closed untill the server is turned off. now how will the connection pooling track these un closed connections? and I will like some one to make me understand with an example of how to implement connection pooling using mysql jdbc. I will be happy if some one gives a complete example including how to define context and where. and how to link it to a web application and how to call the connection from a pool. I have some rough idea but the tomcat docs really confused me. so please help me understand this connection pooling concept thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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]
active and idle connection pooling confusion!
hello, I have been going through the connection pooling docs in the tomcat 5 documentation. and fortunately I found out the sample for mysql jdbc. now there is a confusion. I want to know what is the difference between max active and max idle connections. I mean what is the concept behind these two parameters. and what should be the proportion. where should we find the advantage of idle connections. thanks ] Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
connection pooling confusion help needed
hello all, im going to put a web application in java servlets with tomcat 5 on a production ready server for real time use. I am thinking of using connection pooling but I am a bit confused. I have initialised all my connections in the servlet's init method and closed them in distroy method. so these connections are not closed untill the server is turned off. now how will the connection pooling track these un closed connections? and I will like some one to make me understand with an example of how to implement connection pooling using mysql jdbc. I will be happy if some one gives a complete example including how to define context and where. and how to link it to a web application and how to call the connection from a pool. I have some rough idea but the tomcat docs really confused me. so please help me understand this connection pooling concept thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: connection pooling confusion help needed
Hi All the connection pool properties should be configured in server.xml. You dont have to initialize connections etc. in your init method. you just have to make sure you close your resultset and connection after you are done. Closing it will return it back to the pool. Here is one link from tomcat. Not sure if you took a look at it already http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations Pandu From: Krishnakant Mane [EMAIL PROTECTED] Reply-To: Tomcat Users List tomcat-user@jakarta.apache.org To: tomcat-user@jakarta.apache.org Subject: connection pooling confusion help needed Date: Fri, 25 Mar 2005 19:11:15 + (GMT) hello all, im going to put a web application in java servlets with tomcat 5 on a production ready server for real time use. I am thinking of using connection pooling but I am a bit confused. I have initialised all my connections in the servlet's init method and closed them in distroy method. so these connections are not closed untill the server is turned off. now how will the connection pooling track these un closed connections? and I will like some one to make me understand with an example of how to implement connection pooling using mysql jdbc. I will be happy if some one gives a complete example including how to define context and where. and how to link it to a web application and how to call the connection from a pool. I have some rough idea but the tomcat docs really confused me. so please help me understand this connection pooling concept thanks Krishnakant. Send instant messages to your online friends http://uk.messenger.yahoo.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]
Connection pooling verse one connection per session
Hi, I have a sort of theoretical question. I'm wondering about the pros and cons of using a one connection per tomcat session strategy for connecting to a Postgresql server rather than connection pooling. My users generally login in the morning and keep my app open for extended periods of time, usually serveral hours at least. The one connection per session method seems to work well. Here are the reasons I'm using it. 1. Can cache prepared statements, something that is more problematic to do with a generic connection pool. 2. Have better control of connection releases via the finalize() method in a session helper class that contains the one single connection. 3. Easier to code and implement than connection pooling. 4. Potentially faster than connection pooling because of only one connection open per session. Are there issues that I'm overlooking? If I had more users with shorter sessions, would it make a difference? Thanks. __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection pooling verse one connection per session
On Thu, Mar 10, 2005 at 10:31:41AM -0800, Mark Winslow wrote: : Hi, I have a sort of theoretical question. I'm : wondering about the pros and cons of using a one : connection per tomcat session strategy for connecting : to a Postgresql server rather than connection pooling. The great benefit of pooling is that objects that aren't being (actively) used by one person/login/etc can be used by another. Put another way, the Connection objects aren't specific to a user, so there's no need to treat them as such. (If you've done any EJB, think of Stateless vs Stateful Session Beans.) You say your users are logged into your app all day; but are they constantly streaming data from the minute they login to the minute they logout? If not, then holding open the DB connection for them isn't helping much. (I'd hesitate to say it's doing harm or anything bad, just that it's not helping.) For this same reason, pooling also helps in scalability: when a Connection is idle (not being used by anyone), someone else can use it. : 1. Can cache prepared statements, something that is : more problematic to do with a generic connection pool. True; but have you seen a significant performance gain due to prepared statement caching? : 2. Have better control of connection releases via the : finalize() method in a session helper class that : contains the one single connection. I'm not sure I understand this. If your app is written such that data-access code fetches a Connection as needed, then returns it to the pool when it's done (Connection#close()), then what other control would you need? You realize, for a pooled connection, close() doesn't really shutdown the network connection. It just sends the Connection object back to the pool. : 3. Easier to code and implement than connection : pooling. Again, I don't understand this. Please explain. : 4. Potentially faster than connection pooling because : of only one connection open per session. Yes and no. The connection pool keeps the connection open all the time; so users who go through a pooled Connection object don't suffer any first time access hits. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection pooling verse one connection per session
OK, I see your points and they are well taken. A lot of my concern has to do with this http://jakarta.apache.org/tomcat/tomcat-5.5-doc/printer/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations There is one problem with connection pooling. A web application has to explicetely close ResultSet's, Statement's, and Connection's. So I don't close my result sets, etc. I have say 5 unique connection hits per page. Say the tomcat connection trash collector (set with removeAbandoned=true) runs every 1 minute. In one minute a user can easily hit 5 pages. That's 25 connections I've created and used for that user instead of just 1. Am I wrong about this? A lot of my confusion has to do with the details of how the underlying connection pool code works and how efficient it is. For instance can you assume that the overhead to create a Pooled Connection based an an already established connection is negligable? Releasing it the same thing? There are threading issues involved with connection pools. Do they create inefficient blocking conditions? I understand that there are problems associated with hanging onto a resource like a connection for extended periods of time. It's sort of a non-standard thing to do and maybe not worth any potential cpu/memory benefits. I think I'm probably trying to talk myself into droping my strategy and implementing connection pools. Thanks. --- QM [EMAIL PROTECTED] wrote: On Thu, Mar 10, 2005 at 10:31:41AM -0800, Mark Winslow wrote: : Hi, I have a sort of theoretical question. I'm : wondering about the pros and cons of using a one : connection per tomcat session strategy for connecting : to a Postgresql server rather than connection pooling. The great benefit of pooling is that objects that aren't being (actively) used by one person/login/etc can be used by another. Put another way, the Connection objects aren't specific to a user, so there's no need to treat them as such. (If you've done any EJB, think of Stateless vs Stateful Session Beans.) You say your users are logged into your app all day; but are they constantly streaming data from the minute they login to the minute they logout? If not, then holding open the DB connection for them isn't helping much. (I'd hesitate to say it's doing harm or anything bad, just that it's not helping.) For this same reason, pooling also helps in scalability: when a Connection is idle (not being used by anyone), someone else can use it. : 1. Can cache prepared statements, something that is : more problematic to do with a generic connection pool. True; but have you seen a significant performance gain due to prepared statement caching? : 2. Have better control of connection releases via the : finalize() method in a session helper class that : contains the one single connection. I'm not sure I understand this. If your app is written such that data-access code fetches a Connection as needed, then returns it to the pool when it's done (Connection#close()), then what other control would you need? You realize, for a pooled connection, close() doesn't really shutdown the network connection. It just sends the Connection object back to the pool. : 3. Easier to code and implement than connection : pooling. Again, I don't understand this. Please explain. : 4. Potentially faster than connection pooling because : of only one connection open per session. Yes and no. The connection pool keeps the connection open all the time; so users who go through a pooled Connection object don't suffer any first time access hits. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection pooling verse one connection per session
On Thu, Mar 10, 2005 at 12:30:22PM -0800, Mark Winslow wrote: : http://jakarta.apache.org/tomcat/tomcat-5.5-doc/printer/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations : : There is one problem with connection pooling. A web : application has to explicetely close ResultSet's, : Statement's, and Connection's. I'd hardly say that's a problem; that's just good coding practice. =) (example: When I'm done cooking, I should turn off the stove. Is that a problem with stoves, or just how stoves work?) Connection cleanup maintenance is straightforward: liberally sprinlke finally{} blocks around data access code. -and if that's abstracted out into a layer, and a separate set of objects, you shouldn't have to look in that many places to insert said finally{} blocks. : For instance can you assume that the : overhead to create a Pooled Connection based an an : already established connection is negligable? A pooled connection usually *is* an established connection. The idea of pooling (any sort of object pooling) is that the app (here, Tomcat) instantiates some number of said objects ahead of time, such that they're ready to use when needed. In some cases the objects are created on-demand but then kept around for future use. Pooled Connection objects are wrapped in another object (that also implements Connection) that intercepts close() calls. Instead of actually closing the connection, it returns the object to the pool. : There are threading : issues involved with connection pools. Such as...? As long as you treat a Connection as a hot potato -- hold on to it only as long as you need, then pitch it -- there should be no such threading issues. -and as long as you only fetch Connection objects from the DataSource, then you should never run into an issue where two sections of code get the same Connection. : It's sort of a non-standard thing to : do and maybe not worth any potential cpu/memory : benefits. I think I'm probably trying to talk myself : into droping my strategy and implementing connection : pools. For me, it's mostly a design issue. I design my apps such that I can switch the connection source (pooled, one-off, etc) and the code is none the wiser. It just knows, I get a Connection here, and I call close() on it when I'm done. Whether close() really terminates a network connection/DB session, or just returns an object to the pool, it doesn't matter... -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection pooling verse one connection per session
I'm still not entirely sure about this issue. The close/=null + finally blocks make for pretty ugly and error prone code if you ask me. Why doesn't the connection pool encapsulate closing anyway? Can't it encapsulate closing into the finalize() methods? Are there ordering issues for closing ResultSets, Statements, and Connections? Is infrequent garbage collection an issue? I'm asking about encapsulating into the finalize() methods because I don't like the asthetics of all the close/=null + finally statements. I believe they make for confusing and error prone code and would like a way to make my own encapsulating classes. --- QM [EMAIL PROTECTED] wrote: On Thu, Mar 10, 2005 at 12:30:22PM -0800, Mark Winslow wrote: : http://jakarta.apache.org/tomcat/tomcat-5.5-doc/printer/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations : : There is one problem with connection pooling. A web : application has to explicetely close ResultSet's, : Statement's, and Connection's. I'd hardly say that's a problem; that's just good coding practice. =) (example: When I'm done cooking, I should turn off the stove. Is that a problem with stoves, or just how stoves work?) __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling verse one connection per session
On Thu, Mar 10, 2005 at 10:31:41AM -0800, Mark Winslow wrote: 2. Have better control of connection releases via the finalize() method in a session helper class that contains the one single connection. I hope you meant finally clause rather than finalize() method. A finalize() method is only called when an object is garbage collected, which may not happen for a long, long time, if ever. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling verse one connection per session
if ever.??? Is that really the case? My personal experience with Tomcat is that it does indeed have memory leak problems. In theory, shouldn't all objects created in a web user session eventually be garbage collected after the session ends? I in fact did mean the finalize() method. Is that the main reason not to encapsulate close() methodology there because of slow garbage collection? --- Caldarale, Charles R [EMAIL PROTECTED] wrote: On Thu, Mar 10, 2005 at 10:31:41AM -0800, Mark Winslow wrote: 2. Have better control of connection releases via the finalize() method in a session helper class that contains the one single connection. I hope you meant finally clause rather than finalize() method. A finalize() method is only called when an object is garbage collected, which may not happen for a long, long time, if ever. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Sports - Sign up for Fantasy Baseball. http://baseball.fantasysports.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling verse one connection per session
From: Mark Winslow [mailto:[EMAIL PROTECTED] Subject: RE: Connection pooling verse one connection per session if ever.??? Is that really the case? My personal experience with Tomcat is that it does indeed have memory leak problems. Nearly all the memory leaks I've seen have been in the apps, frequently related to use of static variables to hold references to various session- or request-related items. The few that have actually been a Tomcat problem seem to get fixed fairly quickly. In theory, shouldn't all objects created in a web user session eventually be garbage collected after the session ends? The GC algorithms do not guarantee that any specific object will be collected. If minor (young generation) GCs are sufficient to keep the JVM running, a full (tenured generation) GC need not be performed. Objects in the tenured generation may never be collected and their finalize() methods may then never be called - the JVM may terminate first. I in fact did mean the finalize() method. Is that the main reason not to encapsulate close() methodology there because of slow garbage collection? I don't know that I'd characterize it as slow; the current GC algorithms try to do as little work as possible, so it may be a long time before the desired object gets collected. Since the point at which a finalize() method is called is so indeterminate, its usefulness is rather limited. (Any class with a finalizer method is also somewhat inefficient, since it disrupts GC - each such object must be collected twice - and it slows down object allocation, since each finalizable object has to be registered.) The try {}, catch {}, finally {} sequence is much more robust. - Chuck - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection pooling verse one connection per session
On Thu, Mar 10, 2005 at 01:52:02PM -0800, Mark Winslow wrote: : I'm still not entirely sure about this issue. The : close/=null + finally blocks make for pretty ugly and : error prone code if you ask me. Well, certainly no one's forcing you to code that way. It's just a fairly standard practice in Java webapps to pool DB connections and to use try/catch/finally blocks where appropriate. ;) : Why doesn't the connection pool encapsulate closing : anyway? It seems you're missing the point of the pool. Pooled connections remain open (logged in to the remote DB). The close() method on the Connection wrapper object puts the (underlying) Connection object back in the pool so others can use it. : Can't it encapsulate closing into the : finalize() methods? Maybe it does; but there's no guarantee finalizers will be called. Besides, do you want to wait for gc to run to free up connections? : Are there ordering issues for : closing ResultSets, Statements, and Connections? This is in the docs... I *think* closing a Connection closes all underlying Statement and ResultSet objects, but it's good form to just close them when you're done with them. : Is infrequent garbage collection an issue? If you're waiting for finalizers to do your cleanup work for you, yes. : I'm asking about encapsulating into the finalize() : methods because I don't like the asthetics of all the : close/=null + finally statements. Again, your call. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling verse one connection per session
I don't know. I have one pure Tomcat (no Apache) server that all it does is serve about 300,000 static files per day. The memory usage grows and grows unexplicably. I run a cron job that restarts it everyday, which I had to started running with version 5.0.something or else it would eventually run out of memory and crash. I haven't seen what not restarting will do on 5.5 and the latest version of Java/Linux. I guess I'll try and see. I'm going to switch to using connection pools regardless. I really just had some questions about the standard way of releasing them and gc issues regarding them which have been answered by the nice people on this list. Thanks. Nearly all the memory leaks I've seen have been in the apps, frequently related to use of static variables to hold references to various session- or request-related items. The few that have actually been a Tomcat problem seem to get fixed fairly quickly. __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling verse one connection per session
Sorry, just had one other question about the use of static variables. Can this really be a problem? I thought that a static variable only gets a single copy per JVM/Context. For instance the use of static variables to define formats shouls save on memory usage shouldn't it? public class Helper { public static final DecimalFormat dFormat1 = new DecimalFormat(00); public static final DecimalFormat dFormat2 = new DecimalFormat(#,##0.00); public static final SimpleDateFormat df1 = new SimpleDateFormat(HH:mm); public static final SimpleDateFormat df2 = new SimpleDateFormat(EEE, d MMM, ); } the apps, frequently related to use of static variables to hold references to various session- or __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling verse one connection per session
From: Mark Winslow [mailto:[EMAIL PROTECTED] Subject: RE: Connection pooling verse one connection per session The memory usage grows and grows unexplicably. Modern JVMs also try to avoid doing GC if they can. So, if you've given the JVM a large amount of memory, it will use it all before attempting a GC. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling verse one connection per session
From: Mark Winslow [mailto:[EMAIL PROTECTED] Subject: RE: Connection pooling verse one connection per session Sorry, just had one other question about the use of static variables. Can this really be a problem? I thought that a static variable only gets a single copy per JVM/Context. For instance the use of static variables to define formats shouls save on memory usage shouldn't it? I didn't mean to imply earlier that all static variable usage was bad, just that it can be easily abused in a fashion that leads to memory leaks. The usages you've outlined seem quite appropriate. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cluster and Connection Pooling problem
Define the connection pool in either META-INF/context.xml (if using a WAR) or ${catalina_home}/conf/engine/host/app.xml And the link by the usual resource ref in the web.xml Remember that the JDBC drivers need to be in common/lib PJ Sumpter, Chuck wrote: Environment = Tomcat 5.5.7, Java 1.5_01, IIS (win2k) using the isapi redirector. Problem: Using the scenario outlined by Graham King (http://www.javaworld.com/javaworld/jw-12-2004/jw-1220-tomcat.html ), a simple cluster is easily configured. However, when attempting to deploy our application, I run into a wall attempting to get things in the proper order regarding the connection pooling needed by the application. The application's error log indicates that the connection pooling parms are not really being read in the server.xml. What is the conflict? Anyone else encountered this? I hesitate to supply xml in this forum if someone else has encountered this problem TIA Chuck - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Cluster and Connection Pooling problem
Environment = Tomcat 5.5.7, Java 1.5_01, IIS (win2k) using the isapi redirector. Problem: Using the scenario outlined by Graham King (http://www.javaworld.com/javaworld/jw-12-2004/jw-1220-tomcat.html ), a simple cluster is easily configured. However, when attempting to deploy our application, I run into a wall attempting to get things in the proper order regarding the connection pooling needed by the application. The application's error log indicates that the connection pooling parms are not really being read in the server.xml. What is the conflict? Anyone else encountered this? I hesitate to supply xml in this forum if someone else has encountered this problem TIA Chuck
Tomcat 5 - Datasource Connection Pooling
Finally after long struggle I could get the datasource things running. The things are working when i specified all into GlobalResources and GlobalContext inside server.xml My server.xml is something like below.. - GlobalNamingResources Resource auth=Container name=mspool type=javax.sql.DataSource/ ResourceParams name=mspool parameter nameurl/name valuejdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sbcs/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxActive/name value100/value /parameter parameter namedriverClassName/name valuecom.microsoft.jdbc.sqlserver.SQLServerDriver/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name valuemanisha/value /parameter parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameselectMethod/name valuecursor/value /parameter parameter namepassword/name valuemanisha/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter /ResourceParams /GlobalNamingResources ... Host appBase=webapps name=localhost DefaultContext className=org.apache.catalina.core.StandardDefaultContext ResourceLink global=mspool name=mspool type=javax.sql.DataSource/ /DefaultContext Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=localhost_log. suffix=.txt timestamp=true/ /Host I did not change anything inside Web.xml as everything is inside Global. But i do not want it inside global naming resources / default context - but i want it only specific to my web application. i also understand that Context - should not be used for TomCat5.0 - but need to put inside /META-INF/context.xml. 1)My problem is my working directory is different. I use ant to create war file and then i manually stop the server - delete existing war file / existing directory (This is due to some Win TomCat problem .??..). Then i deploy it using TomCat Manager. It automatically creates META-INF file for me, i do not have META-INF inside my working directory. So where i can put my context.xml ? 2) What shall i put inside context.xml and what shall i put inside server.xml / web/xml ? I tried many different ways but when i use context and as there is no such application (because i delete and re-deploy it) - tomcat server does not run my application. Pls guide me regards Manisha __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: Tomcat 5 - Datasource Connection Pooling
Hi! 1)My problem is my working directory is different. I use ant to create war file and then i manually stop the server - delete existing war file / existing directory (This is due to some Win TomCat problem .??..). Then i deploy it using TomCat Manager. It automatically creates META-INF file for me, i do not have META-INF inside my working directory. So where i can put my context.xml ? You have already answered this yourself, META-INF/ directory of your war file. The only way to avoid the META-INF directory is to not use a war file, as a war file simply is a jar file, and the META-INF is part of the jar file specification. 2) What shall i put inside context.xml and what shall i put inside server.xml / web/xml ? The example pages: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html tells you exactly what to put in each file. You just have to read them one more time and keep focused. I'll give you some hints as well: - Leave server.xml the way it was before you started tampering with it. - Copy CATALINA_HOME/conf/enginename/servername/yourapp.xml, to your context.xml file, and add your resource specification inside the context as in the examples. Then include context.xml in your war file in the META-INF dir. Your app must be running for the yourapp.xml file to exist as it is deleted when you undeploy your app. - In web.xml you need to add a resource-ref as you can see from the examples Good luck Trond - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling with Tomcat 4.1 and SQL Server 2000
Everything you did with the driver,server.xml,web.xml is ok. But it sounds like your driver of sql server 2000 doesnt support connection pooling ... did you tried to connect without the connection pool? i also recommend going to tomcat 5... i had a couple of issues with connection pooling in tomcat 4 with db2 so i went to tomcat 5. now everything is just better. Johnson, Jay escribió: I am trying to establish a connection pool in Tomcat 4.1 to SQL Server 2000. Looking at the SQL Server trace utility, it appears Tomcat connects with the correct username/password and then the following exception is thrown: java.lang.UnsupportedOperationException at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSourc e.java:161). I have taken the following steps: 1)Moved the driver jar files to /common/lib/ 2)Modified the Server.xml file 3)Modified the web.xml file of the application Here is my Server.xml entry: DefaultContext Resource name=jdbc/test auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/test parameter namedriverClassName/name valuecom.microsoft.jdbc.sqlserver.SQLServerDriver/value /parameter parameter nameurl/name valuejdbc:microsoft:sqlserver://localhost:1433/value /parameter parameter nameusername/name valuejay/value /parameter parameter namepassword/name valuejay/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /DefaultContext Here is my entry in the web.xml file: resource-ref descriptionDB Connection/description res-ref-namejdbc/test/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Are any additional entries needed? Any help would be greatly appreciated! Thanks, Jay Johnson - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection Pooling with Tomcat 4.1 and SQL Server 2000
I can connect using my current driver without connection pooling. You may be correct; the driver may not support it. I'm using Microsoft's standard type 4 driver. I'll try using Tomcat 5 also and see if it makes a difference. I'll also see if I can find another driver. Thanks for help! -Original Message- From: Friedrich Gonzalez [mailto:[EMAIL PROTECTED] Sent: Thursday, January 06, 2005 6:10 AM To: Tomcat Users List Subject: Re: Connection Pooling with Tomcat 4.1 and SQL Server 2000 Everything you did with the driver,server.xml,web.xml is ok. But it sounds like your driver of sql server 2000 doesnt support connection pooling ... did you tried to connect without the connection pool? i also recommend going to tomcat 5... i had a couple of issues with connection pooling in tomcat 4 with db2 so i went to tomcat 5. now everything is just better. Johnson, Jay escribió: I am trying to establish a connection pool in Tomcat 4.1 to SQL Server 2000. Looking at the SQL Server trace utility, it appears Tomcat connects with the correct username/password and then the following exception is thrown: java.lang.UnsupportedOperationException at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSourc e.java:161). I have taken the following steps: 1)Moved the driver jar files to /common/lib/ 2)Modified the Server.xml file 3)Modified the web.xml file of the application Here is my Server.xml entry: DefaultContext Resource name=jdbc/test auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/test parameter namedriverClassName/name valuecom.microsoft.jdbc.sqlserver.SQLServerDriver/value /parameter parameter nameurl/name valuejdbc:microsoft:sqlserver://localhost:1433/value /parameter parameter nameusername/name valuejay/value /parameter parameter namepassword/name valuejay/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /DefaultContext Here is my entry in the web.xml file: resource-ref descriptionDB Connection/description res-ref-namejdbc/test/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Are any additional entries needed? Any help would be greatly appreciated! Thanks, Jay Johnson - 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]
Connection Pooling with Tomcat 4.1 and SQL Server 2000
I am trying to establish a connection pool in Tomcat 4.1 to SQL Server 2000. Looking at the SQL Server trace utility, it appears Tomcat connects with the correct username/password and then the following exception is thrown: java.lang.UnsupportedOperationException at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSourc e.java:161). I have taken the following steps: 1)Moved the driver jar files to /common/lib/ 2)Modified the Server.xml file 3)Modified the web.xml file of the application Here is my Server.xml entry: DefaultContext Resource name=jdbc/test auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/test parameter namedriverClassName/name valuecom.microsoft.jdbc.sqlserver.SQLServerDriver/value /parameter parameter nameurl/name valuejdbc:microsoft:sqlserver://localhost:1433/value /parameter parameter nameusername/name valuejay/value /parameter parameter namepassword/name valuejay/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter namemaxWait/name value100/value /parameter /ResourceParams /DefaultContext Here is my entry in the web.xml file: resource-ref descriptionDB Connection/description res-ref-namejdbc/test/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Are any additional entries needed? Any help would be greatly appreciated! Thanks, Jay Johnson
tomcat problem related connection pooling help needed
hello Jan and other friends, I read the mail that was sent as a reply for my problem. thanks jan for ur valuable help. I must mention that I am new to the jdbc stuff. so I could not figure out the connection pooling issue. I understand that with pooling I can have live objects of say connection objects that I can use as a pool and that tomcat can send them when needed. but I don't exactly know how to do it please guide me abt jdbc connection pooling. I know that it is out of topic on this list, but to understand jdbc pooling and my problem related to tomcat, I must first understand in short how pooling in jdbc works. plese help me on these issues. thanks Krishnakant. ___ Win a castle for NYE with your mates and Yahoo! Messenger http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: tomcat problem related connection pooling help needed
ok, i will share what little knowledge i have... when you normaly open a database connection, you get a connection object that represents a database connection, you allways get a new connection and have to ensure that this is definetly closed after usage. there a quite a few drawbacks to this as you _must_ close the connection and in that the number of java connection objects have to correspond to those maximal available from your dbms (e.g. mysql). my first webapp at university was build like that and worked fine till i got load on the system - then it crashed ;) a connection pool helps you in avoiding mentioned problems. it basically is a pool (funny that :) managed by a pool provider that consist of a limited number of actual connection objects. these get created (and in specific cases even destroyed/closed) by the pool provider. all you have to do is configure it according to your specifications and then changed your db code to request connections from the pool. tomcat, beeing the great server it is, comes with a pool provider that you could use to start with. i am not sure whether it is recommended for production so you should check that before going live with your system. you usually will set up a connection pool in combination with a jndi ressource that provides everything needed for your app. first created the mentioned jndi by editing your applications xml file under {TomcatInstallDir}\conf\Catalina\{servername}\myApplicationName.xml you will need to insert a new ressource within the context-tag. the following should serve as a general guideline, you will have to change names, paths etc according to your setup of course :) ?xml version='1.0' encoding='utf-8'? Context ... ... Resource auth=Container name=jdbc/yourDatasourceName type=javax.sql.DataSource/ ResourceParams name=jdbc/yourDatasourceName parameter nameurl/name valuejdbc:mysql://localhost:3306/daxcolog?autoReconnect=true/value /parameter parameter namemaxIdle/name value15/value /parameter parameter namemaxActive/name value50/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameusername/name valuedbUsername/value /parameter parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namepassword/name valuedbPassword/value /parameter /ResourceParams /Context the following two methods illustrate how to retrieve the session from the context afterwards. NOTE: these are quite old as i have been using hibernate for quite some time now, so use them as a general guideline only! private Connection connect() { Connection conn = null; try { Context ctx = new InitialContext(); if (ctx == null) { throw new Exception( BaseTable.connect() -- Could not get Database Context); } DataSource ds = (DataSource) ctx.lookup(java:comp/env/jdbc/yourDatasourceName); if (ds != null) { conn = ds.getConnection(); } } catch (Exception e) { logger.error( Connection error! , e); } return conn; } private void disconnect(Connection conn) { try { java.sql.SQLWarning sqlw = conn.getWarnings(); while (sqlw != null) { logger.error( SQL Warnings: + sqlw); sqlw = sqlw.getNextWarning(); } conn.close(); } catch (Exception e) { logger.error( Error closing connection , e); } conn = null; } there are several good tutorials on this topic as well (just google or look at either the tomcat or mysql driver manual) and i would highly recommend looking into them, especially to ensure that you are closing every statement and connection and that connections are correctly returned to the pool... hth, jan -Original Message- From: Krishnakant Mane [mailto:[EMAIL PROTECTED] Sent: Sunday, December 19, 2004 2:17 PM To: [EMAIL PROTECTED] Subject: tomcat problem related connection pooling help needed hello Jan and other friends, I read the mail that was sent as a reply for my problem. thanks jan for ur valuable help. I must mention that I am new to the jdbc stuff. so I could not figure out the connection pooling issue. I understand that with pooling I can have live objects of say connection objects that I can use as a pool and that tomcat can send them when needed. but I don't exactly know how
Re: connection pooling
thats what I hope this is, the guy who was before me wasnt that great at anything other then coding swing apps, so tomcat the server and database are a mess. From: Filip Hanik - Dev [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: connection pooling Date: Thu, 16 Dec 2004 16:13:03 -0600 depends on what connection pool you use. but in almost all causes, its a pretty trivial thing (unless your code is funky of course) in our system, all we did was to switch the driver name (to the pooled driver), and it would pick up our connection pool. so it was a one line change. Filip - Original Message - From: Didier McGillis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, December 16, 2004 3:49 PM Subject: connection pooling I'm about to the point where I'm going to switch to db connection pooling. however before I undertake this seemly easy task I have a question, which will make this a huge project or a simple one. The current site uses typical MySQL connection, where a connection is opened and so on, if I do connection pooling will I have to go in and do mass code changes? aka will I have to rewrite any servlets or jsps that make database calls. - 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: connection pooling
depends on what connection pool you use. but in almost all causes, its a pretty trivial thing (unless your code is funky of course) in our system, all we did was to switch the driver name (to the pooled driver), and it would pick up our connection pool. so it was a one line change. Filip - Original Message - From: Didier McGillis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, December 16, 2004 3:49 PM Subject: connection pooling I'm about to the point where I'm going to switch to db connection pooling. however before I undertake this seemly easy task I have a question, which will make this a huge project or a simple one. The current site uses typical MySQL connection, where a connection is opened and so on, if I do connection pooling will I have to go in and do mass code changes? aka will I have to rewrite any servlets or jsps that make database calls. - 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]
connection pooling
I'm about to the point where I'm going to switch to db connection pooling. however before I undertake this seemly easy task I have a question, which will make this a huge project or a simple one. The current site uses typical MySQL connection, where a connection is opened and so on, if I do connection pooling will I have to go in and do mass code changes? aka will I have to rewrite any servlets or jsps that make database calls. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat Connection Pooling
Hey I have within my server.xml the following: Resource name=jdbc/postgres auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/postgres parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter nameurl/name valuejdbc:postgresql://penguin.kent.ac.uk:5432/rms_dev/value /parameter parameter nameusername/name valuerms_dev/value /parameter parameter namepassword/name valueisi5gi/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter namemaxWait/name value-1/value /parameter /ResourceParams And I also have the relevant ResourceLink information to get this working. And it does work within my web application. However I want to ensure that this is actually a connection pool. I want to test to see how many connections are in the pool, is there a way? Or can someone tell me for sure if I have set connection pooling up? Thanks Rich - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat 4.1: Setting Up Connection Pooling, Adding Resource to server.xml
The question relates to my home study of the Tomcat Server via the book referenced below. Added Context via Tomcat Administration page. Added Resource, ResourceParams, and parameter tags by hand-editing the server.xml file, and re-starting. Reference: Ian McFarland, Peter Harrison, Mastering Tomcat Development, Wiley Publishing, Inc., p. 283-284. = In Tomcat Administration Page: Clicking on Data Sources, under Resources, under Context /tomcatbook, under Host, gives the following exception, perhaps indicating Tomcat 4.1 is not compatible with this XML setup. Exception truncated for brevity's sake. exception org.apache.jasper.JasperException: Exception retrieving attribute 'driverClassName' at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) = Changes to $CATALINA/HOME/server.xml (Context tag added by Tomcat Administration page, inside Context tag manually added via text editor, as recommended by referenced book): Context className=org.apache.catalina.core.StandardContext cachingAllowed=true charsetMapperClass=org.apache.catalina.util.CharsetMapper cookies=true crossContext=false debug=0 docBase=tomcatbook mapperClass=org.apache.catalina.core.StandardContextMapper path=/tomcatbook privileged=false reloadable=true swallowOutput=false useNaming=false wrapperClass=org.apache.catalina.core.StandardWrapper Resource name=jdbc/tomcatbook auth=Container type=javax.sql.DataSource ResourceParams name=jdbc/tomcatbook parameter nameuser/name valuetomcatbook/value /parameter parameter namepassword/name valuePasswordIntentionallyChangedToProtectMeFromTheGuilty/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost.localdomain/tomcatbook/value /parameter /ResourceParams /Resource /Context = Should I create a New Data Source in the Tomcat Administration Tool? Would the following values be correct? PropertyValue JNDI Name: jdbc/tomcatbook Data Source URL:jdbc:mysql://localhost.localdomain/tomcatbook JDBC Driver Class: com.mysql.jdbc.Driver User Name: tomcat Password: PasswordIntentionallyChangedToProtectMeFromTheGuilty Max. Active Connections:4 Max. Idle Connections: 2 Max. Wait for Connection: 5000 Validation Query: ??? select login, password from user = Server Information Tomcat Version Apache Tomcat/4.1.24-LE-jdk14 JVM Version 1.4.2-b28 JVM Vendor Sun Microsystems Inc. OS Name Linux OS Version 2.4.20-31.9 OS Architecture i386 = Working Java code: import java.sql.* ; public class TestMySQL3 { public static void main ( String [] args ) throws Exception { Class.forName(com.mysql.jdbc.Driver).newInstance(); Connection connection = null ; Statement statement = null ; ResultSet resultSet = null ; String query = select login, password from user ; try { connection = DriverManager.getConnection ( jdbc:mysql://localhost/tomcatbook, tomcat, PasswordIntentionallyChangedToProtectMeFromTheGuilty ) ; statement = connection.createStatement () ; resultSet = statement.executeQuery ( query ) ; while ( resultSet.next () ) { String login= resultSet.getString ( 1 ) ; String password = resultSet.getString ( 2 ) ; System.out.println ( login: + login + password: + password ) ; } } finally { if ( resultSet != null ) resultSet.close () ; if ( statement != null ) statement.close () ; if (
Re: Tomcat 4.1: Setting Up Connection Pooling, Adding Resource to server.xml,
I missed the following important information that was in the Tomcat documentation, that wasn't in the book I was reading. I am currently getting the following exception in my log file when executing a servlet that obtains a DataSource using the JNDI InitialContext. I previously thought it might be a class not defined exception because I didn't supply the connection pooling .jar files as required by the instructions. 2004-11-26 20:15:24 org.apache.catalina.INVOKER.ClientListPooledServlet: ClientListPooledServlet.init: javax.naming.NameNotFoundException: Name java:comp is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) at javax.naming.InitialContext.lookup(InitialContext.java:347) at ClientListPooledServlet.init(ClientListPooledServlet.java:25) From ClientListPooledServlet.java. Line 25 is the one with the new InitialContext () constructor call. public void init ( ServletConfig config ) throws ServletException { super.init ( config ) ; log ( ClientListPooledServlet.init entered ) ; try { // Context initCtx = new InitialContext () ; // Context envCtx = (Context) initCtx.lookup ( java:comp/env ) ; // ds = (DataSource) envCtx.lookup ( jdbc/tomcatbook ) ; ds = (DataSource) new InitialContext ().lookup ( java:comp/env/jdbc/tomcatbook ) ; } catch ( Exception e ) { log ( ClientListPooledServlet.init: + e.getMessage () ) ; log ( ClientListPooledServlet.init: , e ) ; throw new UnavailableException ( e.getMessage () ) ; } log ( ClientListPooledServlet.init exiting ) ; } DBCP uses the Jakarta-Commons Database Connection Pool. It relies on number of Jakarta-Commons componenets: * Jakarta-Commons DBCP 1.0 * Jakarta-Commons Collections 2.0 * Jakarta-Commons Pool 1.0 These jar files along with your the jar file for your JDBC driver should be installed in $CATALINA_HOME/common/lib. I don't know if these versions are close enough, or not. If not, I can go through the Jakarta Archives looking for closer versions. [EMAIL PROTECTED] logs]$ ll -rt $CATALINA_HOME/common/lib ... -rw-r--r--1 davidstevenson 175426 Nov 26 20:06 commons-collections-2.1.1.jar -rw-r--r--1 davidstevenson42492 Nov 26 20:06 commons-pool-1.2.jar -rw-r--r--1 davidstevenson 107631 Nov 26 20:08 commons-dbcp-1.2.1.jar Based on the Tomcat Documentation, I revamped the server.xml configuration (I haven't modified this yet to include the instructions under Preventing dB connection pool leaks in http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html). Context className=org.apache.catalina.core.StandardContext cachingAllowed=true charsetMapperClass=org.apache.catalina.util.CharsetMapper cookies=true crossContext=false debug=9 docBase=tomcatbook mapperClass=org.apache.catalina.core.StandardContextMapper path=/tomcatbook privileged=false reloadable=true swallowOutput=false useNaming=false wrapperClass=org.apache.catalina.core.StandardWrapper displayName=Mastering Tomcat Development Logger className=org.apache.catalina.logger.FileLogger prefix=localhost_tomcatbook_log. suffix=.txt timestamp=true/ Resource name=jdbc/tomcatbook auth=Container type=javax.sql.DataSource ResourceParams name=jdbc/tomcatbook parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name valuetomcat/value /parameter parameter namepassword/name valueRealPasswordOmitted/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost/tomcatbook?autoReconnect=true/value /parameter /ResourceParams /Resource /Context $ more $CATALINA_HOME/webapps/tomcatbook/WEB-INF/web.xml ... resource-ref description This is a reference to the data source we use to talk to the database configured in the server.xml file. /description res-ref-namejdbc/tomcatbook/res-ref-name res
Re: AW: connection pooling
What informix db version are you working with? I do not know how to get the serial value. I use an informix driver that supports connection pooling and I'm not familiar with the ifmxStatement. Depending on the informix version, I suggest utilizing a type 4 informix jdbc driver(search). That may help although you may need to change some code such as the ifmxStatement. I'm in a bit over my head on this one. Eric On Thu, 11 Nov 2004 12:04:28 +0100, Akacem Mohammed [EMAIL PROTECTED] wrote: Hello Eric, thank you Eric it works now. but I have another probleme now: in my code I have the following statements: ifmxStatement informixStmt= (IfmxStatement)stmt; // I get hier a ClassCastException // serialvalue = ((IfmxStatement)stmt).getSerial(); serialvalue = informixStmt.getSerial(); actually I am porting my app from tomcat 4.1 jkd 1.3 to tomcat 5.0.28. jdk 1.4. I earlier used the com.bitmechanic.sql package und I had no casting probleme on this statement. I looked in the ifmx.jar docs, the IfmxStatement implement Statement.that means the implementation of dbcp und ifmx.jar driver are not compatible. have you an idea how to get the serialvalue. I do write the serialvalue I get from informix in a column in my table(it is somhow my increment.) or do you use the pooled version of the informix driver? thanks for any hint Mohammed -Ursprüngliche Nachricht- Von: Eric Wulff [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 10. November 2004 19:26 An: [EMAIL PROTECTED] Betreff: AW: connection pooling Sorry, I sent this to the user list but didn't copy you directly. -- Forwarded message -- From: Eric Wulff [EMAIL PROTECTED] Date: Tue, 9 Nov 2004 11:32:15 -0800 Subject: Re: AW: connection pooling To: Tomcat Users List [EMAIL PROTECTED] Hi Mohammed, The resource-ref of your web.xml looks alright. While the DefaultContext should work if you place it in the correct location(see notes below) within your server.xml, I doubt you want this to be your final solution. My final fix was suggested by Steve and noted here... Copy the Context... (you need to change your DefaultContext tag to a Context tag) from your server.xml to a file all its own and name that file myapp.xml(in your case I guess that would be SteaDB.xml). Then mv that file to $CATALINA_HOME/conf/Catalina/localhost/ Restart your app or shutdown and startup Tomcat and you should be all set. Let me know how it goes. Eric Notes: - I'm not sure if DefaultContext or Context within your server.xml have any effect once you have a myapp.xml at $CATALINA_HOME/conf/Catalina/localhost/. I still have a Context in my server.xml. - I don't think it matters but fyi, my Context only includes a Resource, and then Resource-Params as follows: username, password, driverClass, and url. - When working with the DefaultContext, location for that tag should be within the Engine... tag having the Standalone attribute. This likely needs to be un-commented, hence you will need to comment out the Engine... tag with the Catlina attribute, which is likely just below in the server.xml. On Tue, 9 Nov 2004 14:25:41 +0100, Akacem Mohammed [EMAIL PROTECTED] wrote: Hello, I am stuck in the same Probleme as Erik. I did exactly what in the e-mails suggested is with no success. I am runing TC 5.0.28 und try to get a connection to an informix database. I got the following Error Message: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' mycode : try { initCtx = new InitialContext(); envCtx = (Context) initCtx.lookup(java:comp/env); ds = (DataSource) envCtx.lookup(jdbc/SteaDB); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { conn=ds.getConnection(); } catch (SQLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } My Configuration is as follow: web.xml : resource-ref descriptionDB Connection to informix/description res-ref-namejdbc/SteaDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server.xml : DefaultContext Resource name=jdbc/SteaDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SteaDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/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
AW: connection pooling
Hello, I am stuck in the same Probleme as Erik. I did exactly what in the e-mails suggested is with no success. I am runing TC 5.0.28 und try to get a connection to an informix database. I got the following Error Message: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' mycode : try { initCtx = new InitialContext(); envCtx = (Context) initCtx.lookup(java:comp/env); ds = (DataSource) envCtx.lookup(jdbc/SteaDB); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { conn=ds.getConnection(); } catch (SQLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } My Configuration is as follow: web.xml : resource-ref descriptionDB Connection to informix/description res-ref-namejdbc/SteaDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server.xml : DefaultContext Resource name=jdbc/SteaDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SteaDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/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 !-- username and password for dB connections -- parameter nameusername/name valueunknown/value /parameter parameter namepassword/name valueunknown/value /parameter !-- Class name for the informix treiber -- parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name value jdbc:informix-sqli://s0062033.vt.bb.de:300056/coadb:informixserver=coadbzentral /value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value !-- in second -- /parameter parameter namelogAbandoned/name valuetrue/value /parameter /ResourceParams /DefaultContext thanks for any hint Mohammed -Ursprüngliche Nachricht- Von: Steve Kirk [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 9. November 2004 01:40 An: 'Eric Wulff'; 'Tomcat Users List' Betreff: RE: connection pooling Worth clarifyig what we are meaning by DBCP. The DBCP I was referring to was the specific implementation of connection pooling that is part of Jakarta Commons: http://jakarta.apache.org/commons/dbcp/ There are other pooling implementations which are alternatives to Commons DBCP. Some DB drivers included pooling support as-is. Others do not. For those that do not, you need to implement pooling by building code around the standard driver. You used to have to do this yourself, but now there is DBCP to take care of this for you. DBCP is a wrapper used around a non-pooling DB driver. So, hence my question, are you intending to use DBCP, or does your Informix driver include pooling? From the JNDI/JDBC guides it appears that you have the choice of using DBCP or not (although there is one aspect of the docs that seem slightly unclear on that, which I am going start another thread to clear up). The configs are similar. Personally I have only got the DBCP approach to work, hence my suggestion of using that, for which you need to include the factory parameter. What this does is basically tells TC to call DBCP rather than your database driver when making a connection - DBCP then calls your DB driver if and when it needs to. I think I'm right in saying that if you don't explcitly use DBCP, and your DB driver does not support pooling, you will end up with non-pooled connections. The webapp will still work but you will not have the advantages of pooling. In case it helps, here are my ResourceParams. Note that I have both factory and driverClassName: ResourceParams name=jdbc/myDb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameusername/name valueme/value /parameter parameter namepassword/name valuesecret
Re: AW: connection pooling
I've been dealing with similar issues recently. Basically your reference in web.xml is not 'pointing' to the resource you defined in server.xml for some reason, which is why if you examine the datasource you get, you will see all the fields set to null (as indicated by the error). Try to create a context for your webapp in server.xml and put your resource in there as a first step to debug. If this doesn't work, check your server.xml is being read - i think the log will tell you (?) and / or try with a simple server.xml to eliminate any xml errors. On Tue, 9 Nov 2004 14:25:41 +0100, Akacem Mohammed [EMAIL PROTECTED] wrote: Hello, I am stuck in the same Probleme as Erik. I did exactly what in the e-mails suggested is with no success. I am runing TC 5.0.28 und try to get a connection to an informix database. I got the following Error Message: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' mycode : try { initCtx = new InitialContext(); envCtx = (Context) initCtx.lookup(java:comp/env); ds = (DataSource) envCtx.lookup(jdbc/SteaDB); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { conn=ds.getConnection(); } catch (SQLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } My Configuration is as follow: web.xml : resource-ref descriptionDB Connection to informix/description res-ref-namejdbc/SteaDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server.xml : DefaultContext Resource name=jdbc/SteaDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SteaDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/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 !-- username and password for dB connections -- parameter nameusername/name valueunknown/value /parameter parameter namepassword/name valueunknown/value /parameter !-- Class name for the informix treiber -- parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name value jdbc:informix-sqli://s0062033.vt.bb.de:300056/coadb:informixserver=coadbzentral /value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value !-- in second -- /parameter parameter namelogAbandoned/name valuetrue/value /parameter /ResourceParams /DefaultContext thanks for any hint Mohammed -Ursprüngliche Nachricht- Von: Steve Kirk [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 9. November 2004 01:40 An: 'Eric Wulff'; 'Tomcat Users List' Betreff: RE: connection pooling Worth clarifyig what we are meaning by DBCP. The DBCP I was referring to was the specific implementation of connection pooling that is part of Jakarta Commons: http://jakarta.apache.org/commons/dbcp/ There are other pooling implementations which are alternatives to Commons DBCP. Some DB drivers included pooling support as-is. Others do not. For those that do not, you need to implement pooling by building code around the standard driver. You used to have to do this yourself, but now there is DBCP to take care of this for you. DBCP is a wrapper used around a non-pooling DB driver. So, hence my question, are you intending to use DBCP, or does your Informix driver include pooling? From the JNDI/JDBC guides it appears that you have the choice of using DBCP or not (although there is one aspect of the docs that seem slightly unclear on that, which I am going start another thread to clear up). The configs are similar. Personally I have only got the DBCP approach to work, hence my suggestion of using that, for which you need to include the factory parameter. What this does is basically tells TC to call DBCP rather than your database driver when making a connection - DBCP then calls your DB driver if and when it needs to. I think I'm right in saying that if you don't explcitly use DBCP, and your DB driver does not support pooling, you will end up with non-pooled connections. The webapp will still work but you will not have
Re: AW: connection pooling
Hi Mohammed, The resource-ref of your web.xml looks alright. While the DefaultContext should work if you place it in the correct location(see notes below) within your server.xml, I doubt you want this to be your final solution. My final fix was suggested by Steve and noted here... Copy the Context... (you need to change your DefaultContext tag to a Context tag) from your server.xml to a file all its own and name that file myapp.xml(in your case I guess that would be SteaDB.xml). Then mv that file to $CATALINA_HOME/conf/Catalina/localhost/ Restart your app or shutdown and startup Tomcat and you should be all set. Let me know how it goes. Eric Notes: - I'm not sure if DefaultContext or Context within your server.xml have any effect once you have a myapp.xml at $CATALINA_HOME/conf/Catalina/localhost/. I still have a Context in my server.xml. - I don't think it matters but fyi, my Context only includes a Resource, and then Resource-Params as follows: username, password, driverClass, and url. - When working with the DefaultContext, location for that tag should be within the Engine... tag having the Standalone attribute. This likely needs to be un-commented, hence you will need to comment out the Engine... tag with the Catlina attribute, which is likely just below in the server.xml. On Tue, 9 Nov 2004 14:25:41 +0100, Akacem Mohammed [EMAIL PROTECTED] wrote: Hello, I am stuck in the same Probleme as Erik. I did exactly what in the e-mails suggested is with no success. I am runing TC 5.0.28 und try to get a connection to an informix database. I got the following Error Message: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' mycode : try { initCtx = new InitialContext(); envCtx = (Context) initCtx.lookup(java:comp/env); ds = (DataSource) envCtx.lookup(jdbc/SteaDB); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { conn=ds.getConnection(); } catch (SQLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } My Configuration is as follow: web.xml : resource-ref descriptionDB Connection to informix/description res-ref-namejdbc/SteaDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server.xml : DefaultContext Resource name=jdbc/SteaDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SteaDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/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 !-- username and password for dB connections -- parameter nameusername/name valueunknown/value /parameter parameter namepassword/name valueunknown/value /parameter !-- Class name for the informix treiber -- parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name value jdbc:informix-sqli://s0062033.vt.bb.de:300056/coadb:informixserver=coadbzentral /value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value !-- in second -- /parameter parameter namelogAbandoned/name valuetrue/value /parameter /ResourceParams /DefaultContext thanks for any hint Mohammed -Ursprüngliche Nachricht- Von: Steve Kirk [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 9. November 2004 01:40 An: 'Eric Wulff'; 'Tomcat Users List' Betreff: RE: connection pooling Worth clarifyig what we are meaning by DBCP. The DBCP I was referring to was the specific implementation of connection pooling that is part of Jakarta Commons: http://jakarta.apache.org/commons/dbcp/ There are other pooling implementations which are alternatives to Commons DBCP. Some DB drivers included pooling support as-is. Others do not. For those that do not, you need to implement pooling by building code around the standard driver. You used to have to do this yourself, but now there is DBCP to take care of this for you. DBCP is a wrapper used around a non-pooling DB driver. So, hence my question, are you intending to use DBCP, or does your Informix driver include pooling? From the JNDI/JDBC
Connection pooling under Tomcat 5.0.28 Probleme
Hello every body, I have read in die archive the e-mail exchange about configuring Datasource in Tomcat for connection pooling. ( I also read the Tomcat doc ) the jar file commons-collection- 3.1.jar, commons-dbcp-1.2.1.jar, commons-pool-1.2.jar und the database driver ifjdbc.jar are in the commons/lib directory. I got the following Mersage Cannot create JDBC driver of class '' for connect URL 'null' ( someone on the list experienced the same thing with the same Message ) My Configuration is as follow: ( I try to access an informix database ) web.xml : resource-ref descriptionDB Connection to informix/description res-ref-namejdbc/SteaDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Server.xml : DefaultContext Resource name=jdbc/SteaDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SteaDB parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/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 !-- username and password for dB connections -- parameter nameusername/name valueusernamer/value /parameter parameter namepassword/name valuedfdfdf/value /parameter !-- Class name for the informix treiber -- parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name value jdbc:informix-sqli://s0062033.vt.bb.de:300056/coadb:informixserver=coadbzentral /value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value !-- in second -- /parameter parameter namelogAbandoned/name valuetrue/value /parameter /ResourceParams /DefaultContext Thank you for your help Mohammed - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: connection pooling
Worth clarifyig what we are meaning by DBCP. The DBCP I was referring to was the specific implementation of connection pooling that is part of Jakarta Commons: http://jakarta.apache.org/commons/dbcp/ There are other pooling implementations which are alternatives to Commons DBCP. Some DB drivers included pooling support as-is. Others do not. For those that do not, you need to implement pooling by building code around the standard driver. You used to have to do this yourself, but now there is DBCP to take care of this for you. DBCP is a wrapper used around a non-pooling DB driver. So, hence my question, are you intending to use DBCP, or does your Informix driver include pooling? From the JNDI/JDBC guides it appears that you have the choice of using DBCP or not (although there is one aspect of the docs that seem slightly unclear on that, which I am going start another thread to clear up). The configs are similar. Personally I have only got the DBCP approach to work, hence my suggestion of using that, for which you need to include the factory parameter. What this does is basically tells TC to call DBCP rather than your database driver when making a connection - DBCP then calls your DB driver if and when it needs to. I think I'm right in saying that if you don't explcitly use DBCP, and your DB driver does not support pooling, you will end up with non-pooled connections. The webapp will still work but you will not have the advantages of pooling. In case it helps, here are my ResourceParams. Note that I have both factory and driverClassName: ResourceParams name=jdbc/myDb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameusername/name valueme/value /parameter parameter namepassword/name valuesecret/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/myDb/value /parameter /ResourceParams -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: Friday 05 November 2004 18:34 To: Steve Kirk Cc: Tomcat Users List Subject: Re: connection pooling Steve, I am trying to use DBCP(hence the subject of the thread) and I believe I have a driver that supports it. Especially considering that the connection works when I wrap my data resource in a DefaultContext tag inside a stand alone Engine tag(server.xml), instead of inside a Context tag(how all instructions I've followed so far suggest). This means my driver support DBCP, correct? The only source code I imagine would help is the code I use to gain connection... Context initialContext = new InitialContext(); Context context = (Context) initialContext.lookup(java:comp/env); DataSource dataSource = (DataSource) context.lookup(jdbc/wms); connection = dataSource.getConnection(); I have seen no mention of this factory class parameter you speak of. I'm using TC 5.0.28. I'll try it. thx much for your help Eric On Fri, 5 Nov 2004 13:30:35 -, Steve Kirk [EMAIL PROTECTED] wrote: Eric - you are correct, you do not need both resource-ref and Resource (although I've found that having both does not cause a problem). Back to your problem. The error message indicates that TC cannot find the Resource. I'm not sure if you are trying to use DBCP or not (in other words, does the informix driver support pooling on its own, or do you in fact need DBCP or some other implementation wrapped around it)? You have res-typejavax.sql.DataSource/res-type but do not list the factory class under your Resource, e.g. : parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter I have not seen any Java source code on this thread, maybe you posted it before I started reading it. Thinking slightly laterally I'll pass on something I learned from Yoav recently on this list you don't need to use container-managed resources to do connection pooling. In other words you don't need to set any Resource or Context to get it to work. -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: Friday 05 November 2004 05:57 To: Tomcat Users List; Atishay Kumar Subject: Re: connection pooling Thx for your input but, as mentioned in my previous message, I've tried this and it does not work. Also, considering my web.xml I shouldn't need this, correct? I have a resource-ref in my web.xml. Eric
Re: connection pooling
Well, my informix driver does support connection pooling as-is so I do not need to use a Jakarta Commons DBCP wrapper in order to take advantage of database connection pooling. Thx for clarifying and for sharing your ResourceParams. I need to study this issue some more in general since I only have a surface understanding of what connection pooling really is and what it's advantages are. For now, my app is successfully utilizing connection pooling, as far as I can tell. My problem, which initiated this thread, has been solved by putting a myapp.xml with the necessary context in my $CATALINA_HOME/conf/Catalina/localhost/ directory. thx Eric On Tue, 9 Nov 2004 00:40:23 -, Steve Kirk [EMAIL PROTECTED] wrote: Worth clarifyig what we are meaning by DBCP. The DBCP I was referring to was the specific implementation of connection pooling that is part of Jakarta Commons: http://jakarta.apache.org/commons/dbcp/ There are other pooling implementations which are alternatives to Commons DBCP. Some DB drivers included pooling support as-is. Others do not. For those that do not, you need to implement pooling by building code around the standard driver. You used to have to do this yourself, but now there is DBCP to take care of this for you. DBCP is a wrapper used around a non-pooling DB driver. So, hence my question, are you intending to use DBCP, or does your Informix driver include pooling? From the JNDI/JDBC guides it appears that you have the choice of using DBCP or not (although there is one aspect of the docs that seem slightly unclear on that, which I am going start another thread to clear up). The configs are similar. Personally I have only got the DBCP approach to work, hence my suggestion of using that, for which you need to include the factory parameter. What this does is basically tells TC to call DBCP rather than your database driver when making a connection - DBCP then calls your DB driver if and when it needs to. I think I'm right in saying that if you don't explcitly use DBCP, and your DB driver does not support pooling, you will end up with non-pooled connections. The webapp will still work but you will not have the advantages of pooling. In case it helps, here are my ResourceParams. Note that I have both factory and driverClassName: ResourceParams name=jdbc/myDb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameusername/name valueme/value /parameter parameter namepassword/name valuesecret/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/myDb/value /parameter /ResourceParams -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: Friday 05 November 2004 18:34 To: Steve Kirk Cc: Tomcat Users List Subject: Re: connection pooling Steve, I am trying to use DBCP(hence the subject of the thread) and I believe I have a driver that supports it. Especially considering that the connection works when I wrap my data resource in a DefaultContext tag inside a stand alone Engine tag(server.xml), instead of inside a Context tag(how all instructions I've followed so far suggest). This means my driver support DBCP, correct? The only source code I imagine would help is the code I use to gain connection... Context initialContext = new InitialContext(); Context context = (Context) initialContext.lookup(java:comp/env); DataSource dataSource = (DataSource) context.lookup(jdbc/wms); connection = dataSource.getConnection(); I have seen no mention of this factory class parameter you speak of. I'm using TC 5.0.28. I'll try it. thx much for your help Eric On Fri, 5 Nov 2004 13:30:35 -, Steve Kirk [EMAIL PROTECTED] wrote: Eric - you are correct, you do not need both resource-ref and Resource (although I've found that having both does not cause a problem). Back to your problem. The error message indicates that TC cannot find the Resource. I'm not sure if you are trying to use DBCP or not (in other words, does the informix driver support pooling on its own, or do you in fact need DBCP or some other implementation wrapped around it)? You have res-typejavax.sql.DataSource/res-type but do not list the factory class under your Resource, e.g. : parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter
Re: AW: {an alternative}Re: connection pooling
What escapes me is, why is this not more obviously documented? Perhaps it's in the Tomcat docs but I mostly abandoned those some time ago as they are so amazingly detailed and lengthy that unless you want to become a TC guru, which I am inspired to try and be more like, there is simply too much info. How can you post a paragraph like that and expect to be taken seriously? In one breath, you complain about something not being documented, then state that you don't read the documentation because it's too detailed? How can you know what is or isn't obviously documented if you don't read the documentation? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: {an alternative}Re: connection pooling
in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection pooling Yes, I have added Resource name=... . Now different errors are reported via stack trace as I posted in response to Atishay's suggestion that I add this. I'll try adding your suggestions and see what happens. Also, you suggest adding many parameters. Are they necessary for simply making a connection? If so, the tutorial I'm following, 'Tomcat Kick Start' left all -- :) Atishay Kumar Btech, SEM VII DA-IICT Gandhinagar - 382009 India ph: +91 9825383948 / * Learn the rules as you would need them to break them properly * / -- :) Atishay Kumar Btech, SEM VII DA-IICT Gandhinagar - 382009 India ph: +91 9825383948 / * Learn the rules as you would need them to break them properly * / - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connection pooling
How about try to move your application (wms) out of the webapps directory, let's say: c:\wms Then in the server.xml, try to change docBase in the context: docBase=c:\wms Now, see if your application works or give a different error. Remember to drop the jdbc library into the common/lib folder. Eric Wulff wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... resource-ref res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server xml(tried this with and without a Resource name)... Context path=/wms docBase=wms debug=0 reloadable=true ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSERVER=serverName/value /parameter /ResourceParams /Context I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection pooling Yes, I have added Resource name=... . Now different errors are reported via stack trace as I posted in response to Atishay's suggestion that I add this. I'll try adding your suggestions and see what happens. Also, you suggest adding many parameters. Are they necessary for simply making a connection? If so, the tutorial I'm following, 'Tomcat Kick Start' left all your suggestions out. Including the Resource tag, but that seems critical for connection. Eric On Thu, 7 Oct 2004 17:14:27 -0400, Phillip Qin [EMAIL PROTECTED] wrote: 1. web.xml: OK 2. context.xml on context of server.xml: Resource name=jdbc/test_connect auth=Container type=javax.sql.DataSource/ = have you added this? ResourceParams name=jdbc/test_connect parameter namedriverClassName/name valueyour.jdbc.driver/value /parameter parameter nameurl/name valueyour.jdbc.url/value /parameter parameter nameusername/name valueyouruser/value /parameter parameter namepassword/name valueyourpass/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter nameminIdle/name value10/value
RE: connection pooling
Eric - you are correct, you do not need both resource-ref and Resource (although I've found that having both does not cause a problem). Back to your problem. The error message indicates that TC cannot find the Resource. I'm not sure if you are trying to use DBCP or not (in other words, does the informix driver support pooling on its own, or do you in fact need DBCP or some other implementation wrapped around it)? You have res-typejavax.sql.DataSource/res-type but do not list the factory class under your Resource, e.g. : parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter I have not seen any Java source code on this thread, maybe you posted it before I started reading it. Thinking slightly laterally I'll pass on something I learned from Yoav recently on this list you don't need to use container-managed resources to do connection pooling. In other words you don't need to set any Resource or Context to get it to work. -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: Friday 05 November 2004 05:57 To: Tomcat Users List; Atishay Kumar Subject: Re: connection pooling Thx for your input but, as mentioned in my previous message, I've tried this and it does not work. Also, considering my web.xml I shouldn't need this, correct? I have a resource-ref in my web.xml. Eric On Fri, 5 Nov 2004 11:01:05 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: Pls do the following change after context.. and u are on!! cheers On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... resource-ref res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server xml(tried this with and without a Resource name)... Context path=/wms docBase=wms debug=0 reloadable=true Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORM IXSERVER=serverName/value /parameter /ResourceParams /Context I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote
RE: connection pooling
Hi, Eric - you are correct, you do not need both resource-ref and Resource That's only because we try to accommodate less able developers/administrators. You DO need resource-ref if you want your app to be compliant with the Servlet Specification and portable to other containers. Yoav Shapira http://www.yoavshapira.com 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: connection pooling
Ah yes I agree, but that's not quite what I was saying. Eric, sorry if that was misleading. Eric has a resource-ref already. I meant that if you have resource-ref you do not need Resource as well in TC, because this is what the TC docs say, and the Resource tag is a TC invention rather than something required by the servlet spec. I think Yoav is saying that in fact TC allows you to be slightly loose by omitting the resource-ref as long as you have the Resource, even though strictly speaking you are not spec-compliant if you do this. -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Friday 05 November 2004 13:32 To: Tomcat Users List Subject: RE: connection pooling Hi, Eric - you are correct, you do not need both resource-ref and Resource That's only because we try to accommodate less able developers/administrators. You DO need resource-ref if you want your app to be compliant with the Servlet Specification and portable to other containers. Yoav Shapira http://www.yoavshapira.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: {an alternative}Re: connection pooling
Eric said: Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. when you deploy a mywebapp from a warfile that includes a META-INF/context.xml, TC copies that file to conf/Catalina/localhost/mywebapp.xml. having said that there appear to be situations where TC does and does not copy that file. all I can say is that it works for me (5.0.28). Or, you can create that file yourself. whichever way it's created, its contents are taken as though they were inserted as a context under the Catalina/localhost host in server.xml. this is the preferred way to config a context since v5.x (rather than putting it in server.xml). manager.xml is for the manager webapp. -Original Message- From: Nick Pellow [mailto:[EMAIL PROTECTED] Sent: Friday 05 November 2004 07:40 To: Tomcat Users List Subject: AW: {an alternative}Re: connection pooling HI Eric, I have seen the same error your are getting. I am using tomcat 5.0.28. Make sure that you have removed the expanded war directories, from webapps and ${CATALINA_HOME}/work before restarting. Also look inside those other context.xmls inside ${CATALINA_HOME}/conf/Catalina/localhost and make sure that they do not define a context with path=/wms. Cheers, nick. -Ursprungliche Nachricht- Von: Eric Wulff [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 5. November 2004 07:35 An: Atishay Kumar Cc: Tomcat Users List Betreff: Re: {an alternative}Re: connection pooling Atishay, the DefaultContext does work once I comment out the other Engine element. You mentioned that means something is wrong with my Context? So what next? many thx Eric On Thu, 4 Nov 2004 22:21:57 -0800, Eric Wulff [EMAIL PROTECTED] wrote: This did not work. In looking for the Engine element you speak of I didn't find it exactly. I did find it with it with an extra attribute Engine name=Standalone... jvmRoute=jvm1. Furthermore, this element was nested within the Service element and there is another Engine name=Catalina... element. I tried with and without the jvmRoute element. No success. Same exception. Eric On Fri, 5 Nov 2004 11:20:26 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: If adding Resouce name .../ did not work..then try following On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... the following shld be in web-app resource-ref descriptionMy Datasource/description res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app !-- I am sure u have this right-- server xml(tried this with and without a Resource name)... The following shld be under Engine name=Standalone defaultHost=localhost debug=0 REplace Context path=/wms docBase=wms debug=0 reloadable=true with DefaultContext Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSER VER=serverName/value /parameter /ResourceParams replace /Context with /DefaultContext !-- If this works them there is something wrong with your context. we shall figure that out later but first
Re: AW: {an alternative}Re: connection pooling
I thought I have read back in this same thread that he had two Engine under a Service ? Only one Engine is allowed per Service to fix one problem. --- Nick Pellow [EMAIL PROTECTED] wrote: HI Eric, I have seen the same error your are getting. I am using tomcat 5.0.28. Make sure that you have removed the expanded war directories, from webapps and ${CATALINA_HOME}/work before restarting. Also look inside those other context.xmls inside ${CATALINA_HOME}/conf/Catalina/localhost and make sure that they do not define a context with path=/wms. Cheers, nick. -Ursprungliche Nachricht- Von: Eric Wulff [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 5. November 2004 07:35 An: Atishay Kumar Cc: Tomcat Users List Betreff: Re: {an alternative}Re: connection pooling Atishay, the DefaultContext does work once I comment out the other Engine element. You mentioned that means something is wrong with my Context? So what next? many thx Eric On Thu, 4 Nov 2004 22:21:57 -0800, Eric Wulff [EMAIL PROTECTED] wrote: This did not work. In looking for the Engine element you speak of I didn't find it exactly. I did find it with it with an extra attribute Engine name=Standalone... jvmRoute=jvm1. Furthermore, this element was nested within the Service element and there is another Engine name=Catalina... element. I tried with and without the jvmRoute element. No success. Same exception. Eric On Fri, 5 Nov 2004 11:20:26 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: If adding Resouce name .../ did not work..then try following On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... the following shld be in web-app resource-ref descriptionMy Datasource/description res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app !-- I am sure u have this right-- server xml(tried this with and without a Resource name)... The following shld be under Engine name=Standalone defaultHost=localhost debug=0 REplace Context path=/wms docBase=wms debug=0 reloadable=true with DefaultContext Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSER VER=serverName/value /parameter /ResourceParams replace /Context with /DefaultContext !-- If this works them there is something wrong with your context. we shall figure that out later but first DefaultContext should work!! restart tommy after making changes. hope it works!! -- I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site
Re: connection pooling
Steve, I am trying to use DBCP(hence the subject of the thread) and I believe I have a driver that supports it. Especially considering that the connection works when I wrap my data resource in a DefaultContext tag inside a stand alone Engine tag(server.xml), instead of inside a Context tag(how all instructions I've followed so far suggest). This means my driver support DBCP, correct? The only source code I imagine would help is the code I use to gain connection... Context initialContext = new InitialContext(); Context context = (Context) initialContext.lookup(java:comp/env); DataSource dataSource = (DataSource) context.lookup(jdbc/wms); connection = dataSource.getConnection(); I have seen no mention of this factory class parameter you speak of. I'm using TC 5.0.28. I'll try it. thx much for your help Eric On Fri, 5 Nov 2004 13:30:35 -, Steve Kirk [EMAIL PROTECTED] wrote: Eric - you are correct, you do not need both resource-ref and Resource (although I've found that having both does not cause a problem). Back to your problem. The error message indicates that TC cannot find the Resource. I'm not sure if you are trying to use DBCP or not (in other words, does the informix driver support pooling on its own, or do you in fact need DBCP or some other implementation wrapped around it)? You have res-typejavax.sql.DataSource/res-type but do not list the factory class under your Resource, e.g. : parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter I have not seen any Java source code on this thread, maybe you posted it before I started reading it. Thinking slightly laterally I'll pass on something I learned from Yoav recently on this list you don't need to use container-managed resources to do connection pooling. In other words you don't need to set any Resource or Context to get it to work. -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: Friday 05 November 2004 05:57 To: Tomcat Users List; Atishay Kumar Subject: Re: connection pooling Thx for your input but, as mentioned in my previous message, I've tried this and it does not work. Also, considering my web.xml I shouldn't need this, correct? I have a resource-ref in my web.xml. Eric On Fri, 5 Nov 2004 11:01:05 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: Pls do the following change after context.. and u are on!! cheers On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... resource-ref res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server xml(tried this with and without a Resource name)... Context path=/wms docBase=wms debug=0 reloadable=true Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORM IXSERVER=serverName/value /parameter /ResourceParams /Context I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar
Re: AW: {an alternative}Re: connection pooling
OK - Got It! Thank you all many times over for your time and help on this connection pool thing. It is surprisingly difficult to maintain a stable environment if you're a curious beginner. I clearly need to get a grip on Tomcat's process BUT it also seems abundantly clear that docs/how to's for simply getting started with connection pools are less than optimal. What exactly was my problem? Still not sure and trying to narrow it down. In the hopes of helping anyone on this list, here's what FINALLY worked for me? Again, I'm running TC 5.0.28 on Linux FC2 1. I went in and cleared out ALL my test web-apps, of which I wrote about 6 different toys via tutorials and on my own. While I don't nearly understand the reasons for much of the TC directory structure, I traversed the following directories and 'rm -r -f' all the webaps I created and no longer wanted with the thinking that somehow they might be in the way... the obvious... CATALINA_HOME/webaps/ the less obvious to me... CATALINA_HOME/work/StandAlone/localhost CATALINA_HOME/work/Catalina/localhost 2. This, I'm guessing, is more likely the key but I didn't test between doing all this. I created a new file, myapp.xml, in... CATALINA_HOME/conf/Catalina/localhost/ and simply copied the related Context/Context(see prior emails) from the server.xml in... CATALINA_HOME/conf/ to this file. What escapes me is, why is this not more obviously documented? Perhaps it's in the Tomcat docs but I mostly abandoned those some time ago as they are so amazingly detailed and lengthy that unless you want to become a TC guru, which I am inspired to try and be more like, there is simply too much info. Okay, I'm off to continue figuring why TC keeps crashing on me. Hopefully something I did here solved that problem too. thx again all, Eric On Fri, 5 Nov 2004 08:39:30 +0100, Nick Pellow [EMAIL PROTECTED] wrote: HI Eric, I have seen the same error your are getting. I am using tomcat 5.0.28. Make sure that you have removed the expanded war directories, from webapps and ${CATALINA_HOME}/work before restarting. Also look inside those other context.xmls inside ${CATALINA_HOME}/conf/Catalina/localhost and make sure that they do not define a context with path=/wms. Cheers, nick. -Ursprungliche Nachricht- Von: Eric Wulff [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 5. November 2004 07:35 An: Atishay Kumar Cc: Tomcat Users List Betreff: Re: {an alternative}Re: connection pooling Atishay, the DefaultContext does work once I comment out the other Engine element. You mentioned that means something is wrong with my Context? So what next? many thx Eric On Thu, 4 Nov 2004 22:21:57 -0800, Eric Wulff [EMAIL PROTECTED] wrote: This did not work. In looking for the Engine element you speak of I didn't find it exactly. I did find it with it with an extra attribute Engine name=Standalone... jvmRoute=jvm1. Furthermore, this element was nested within the Service element and there is another Engine name=Catalina... element. I tried with and without the jvmRoute element. No success. Same exception. Eric On Fri, 5 Nov 2004 11:20:26 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: If adding Resouce name .../ did not work..then try following On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... the following shld be in web-app resource-ref descriptionMy Datasource/description res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app !-- I am sure u have this right-- server xml(tried this with and without a Resource name)... The following shld be under Engine name=Standalone defaultHost=localhost debug=0 REplace Context path=/wms docBase=wms debug=0 reloadable=true with DefaultContext Resource name=jdbc/wms auth=Container type=javax.sql.DataSource
Re: connection pooling
Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... resource-ref res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server xml(tried this with and without a Resource name)... Context path=/wms docBase=wms debug=0 reloadable=true ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSERVER=serverName/value /parameter /ResourceParams /Context I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection pooling Yes, I have added Resource name=... . Now different errors are reported via stack trace as I posted in response to Atishay's suggestion that I add this. I'll try adding your suggestions and see what happens. Also, you suggest adding many parameters. Are they necessary for simply making a connection? If so, the tutorial I'm following, 'Tomcat Kick Start' left all your suggestions out. Including the Resource tag, but that seems critical for connection. Eric On Thu, 7 Oct 2004 17:14:27 -0400, Phillip Qin [EMAIL PROTECTED] wrote: 1. web.xml: OK 2. context.xml on context of server.xml: Resource name=jdbc/test_connect auth=Container type=javax.sql.DataSource/ = have you added this? ResourceParams name=jdbc/test_connect parameter namedriverClassName/name valueyour.jdbc.driver/value /parameter parameter nameurl/name valueyour.jdbc.url/value /parameter parameter nameusername/name valueyouruser/value /parameter parameter namepassword/name valueyourpass/value /parameter parameter namemaxActive/name value20/value /parameter parameter namemaxIdle/name value10/value /parameter parameter nameminIdle/name value10/value /parameter parameter
Re: connection pooling
Pls do the following change after context.. and u are on!! cheers On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... resource-ref res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server xml(tried this with and without a Resource name)... Context path=/wms docBase=wms debug=0 reloadable=true Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSERVER=serverName/value /parameter /ResourceParams /Context I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection pooling Yes, I have added Resource name=... . Now different errors are reported via stack trace as I posted in response to Atishay's suggestion that I add this. I'll try adding your suggestions and see what happens. Also, you suggest adding many parameters. Are they necessary for simply making a connection? If so, the tutorial I'm following, 'Tomcat Kick Start' left all your suggestions out. Including the Resource tag, but that seems critical for connection. Eric On Thu, 7 Oct 2004 17:14:27 -0400, Phillip Qin [EMAIL PROTECTED] wrote: 1. web.xml: OK 2. context.xml on context of server.xml: Resource name=jdbc/test_connect auth=Container type=javax.sql.DataSource/ = have you added this? ResourceParams name=jdbc/test_connect parameter namedriverClassName/name valueyour.jdbc.driver/value /parameter parameter nameurl/name valueyour.jdbc.url/value /parameter parameter nameusername/name valueyouruser/value /parameter parameter namepassword/name valueyourpass/value /parameter parameter
{an alternative}Re: connection pooling
If adding Resouce name .../ did not work..then try following On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... the following shld be in web-app resource-ref descriptionMy Datasource/description res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app !-- I am sure u have this right-- server xml(tried this with and without a Resource name)... The following shld be under Engine name=Standalone defaultHost=localhost debug=0 REplace Context path=/wms docBase=wms debug=0 reloadable=true with DefaultContext Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSERVER=serverName/value /parameter /ResourceParams replace /Context with /DefaultContext !-- If this works them there is something wrong with your context. we shall figure that out later but first DefaultContext should work!! restart tommy after making changes. hope it works!! -- I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection pooling Yes, I have added Resource name=... . Now different errors are reported via stack trace as I posted in response to Atishay's suggestion that I add this. I'll try adding your suggestions and see what happens. Also, you suggest adding many parameters. Are they necessary for simply making a connection? If so, the tutorial I'm following, 'Tomcat Kick Start' left all -- :) Atishay Kumar Btech, SEM VII DA-IICT Gandhinagar - 382009 India ph: +91 9825383948 / * Learn the rules as you would need them to break them properly * / - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connection pooling
Thx for your input but, as mentioned in my previous message, I've tried this and it does not work. Also, considering my web.xml I shouldn't need this, correct? I have a resource-ref in my web.xml. Eric On Fri, 5 Nov 2004 11:01:05 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: Pls do the following change after context.. and u are on!! cheers On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... resource-ref res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref server xml(tried this with and without a Resource name)... Context path=/wms docBase=wms debug=0 reloadable=true Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSERVER=serverName/value /parameter /ResourceParams /Context I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection pooling Yes, I have added Resource name=... . Now different errors are reported via stack trace as I posted in response to Atishay's suggestion that I add this. I'll try adding your suggestions and see what happens. Also, you suggest adding many parameters. Are they necessary for simply making a connection? If so, the tutorial I'm following, 'Tomcat Kick Start' left all your suggestions out. Including the Resource tag, but that seems critical for connection. Eric On Thu, 7 Oct 2004 17:14:27 -0400, Phillip Qin [EMAIL PROTECTED] wrote: 1. web.xml: OK 2. context.xml on context of server.xml: Resource name=jdbc/test_connect auth=Container type=javax.sql.DataSource/ = have you added this? ResourceParams name=jdbc/test_connect parameter namedriverClassName/name valueyour.jdbc.driver/value /parameter
Re: {an alternative}Re: connection pooling
This did not work. In looking for the Engine element you speak of I didn't find it exactly. I did find it with it with an extra attribute Engine name=Standalone... jvmRoute=jvm1. Furthermore, this element was nested within the Service element and there is another Engine name=Catalina... element. I tried with and without the jvmRoute element. No success. Same exception. Eric On Fri, 5 Nov 2004 11:20:26 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: If adding Resouce name .../ did not work..then try following On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... the following shld be in web-app resource-ref descriptionMy Datasource/description res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app !-- I am sure u have this right-- server xml(tried this with and without a Resource name)... The following shld be under Engine name=Standalone defaultHost=localhost debug=0 REplace Context path=/wms docBase=wms debug=0 reloadable=true with DefaultContext Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSERVER=serverName/value /parameter /ResourceParams replace /Context with /DefaultContext !-- If this works them there is something wrong with your context. we shall figure that out later but first DefaultContext should work!! restart tommy after making changes. hope it works!! -- I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection pooling Yes, I have added Resource name=... . Now different errors are reported via stack trace as I posted in response to Atishay's suggestion that I add this. I'll try adding your suggestions and see what happens. Also, you suggest adding many parameters. Are they necessary for simply making a connection? If so, the tutorial I'm following, 'Tomcat
Re: {an alternative}Re: connection pooling
Atishay, the DefaultContext does work once I comment out the other Engine element. You mentioned that means something is wrong with my Context? So what next? many thx Eric On Thu, 4 Nov 2004 22:21:57 -0800, Eric Wulff [EMAIL PROTECTED] wrote: This did not work. In looking for the Engine element you speak of I didn't find it exactly. I did find it with it with an extra attribute Engine name=Standalone... jvmRoute=jvm1. Furthermore, this element was nested within the Service element and there is another Engine name=Catalina... element. I tried with and without the jvmRoute element. No success. Same exception. Eric On Fri, 5 Nov 2004 11:20:26 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: If adding Resouce name .../ did not work..then try following On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... the following shld be in web-app resource-ref descriptionMy Datasource/description res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app !-- I am sure u have this right-- server xml(tried this with and without a Resource name)... The following shld be under Engine name=Standalone defaultHost=localhost debug=0 REplace Context path=/wms docBase=wms debug=0 reloadable=true with DefaultContext Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSERVER=serverName/value /parameter /ResourceParams replace /Context with /DefaultContext !-- If this works them there is something wrong with your context. we shall figure that out later but first DefaultContext should work!! restart tommy after making changes. hope it works!! -- I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db and manipulate data via DriverManager.getConnection(url, db, pwd). The driver is located in CATALINA_HOME/commons/lib Eric On Thu, 7 Oct 2004 18:22:45 -0400, Phillip Qin [EMAIL PROTECTED] wrote: No, you don't need that many params. I think your problem might be the driver. Where did you drop off your informix jdbc jar? -Original Message- From: Eric Wulff [mailto:[EMAIL PROTECTED] Sent: October 7, 2004 5:56 PM To: Tomcat Users List Subject: Re: connection
AW: {an alternative}Re: connection pooling
HI Eric, I have seen the same error your are getting. I am using tomcat 5.0.28. Make sure that you have removed the expanded war directories, from webapps and ${CATALINA_HOME}/work before restarting. Also look inside those other context.xmls inside ${CATALINA_HOME}/conf/Catalina/localhost and make sure that they do not define a context with path=/wms. Cheers, nick. -Ursprungliche Nachricht- Von: Eric Wulff [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 5. November 2004 07:35 An: Atishay Kumar Cc: Tomcat Users List Betreff: Re: {an alternative}Re: connection pooling Atishay, the DefaultContext does work once I comment out the other Engine element. You mentioned that means something is wrong with my Context? So what next? many thx Eric On Thu, 4 Nov 2004 22:21:57 -0800, Eric Wulff [EMAIL PROTECTED] wrote: This did not work. In looking for the Engine element you speak of I didn't find it exactly. I did find it with it with an extra attribute Engine name=Standalone... jvmRoute=jvm1. Furthermore, this element was nested within the Service element and there is another Engine name=Catalina... element. I tried with and without the jvmRoute element. No success. Same exception. Eric On Fri, 5 Nov 2004 11:20:26 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: If adding Resouce name .../ did not work..then try following On Thu, 4 Nov 2004 19:46:30 -0800, Eric Wulff [EMAIL PROTECTED] wrote: Hi all, I'm returning to a problem I couldn't solve the first time, about two months ago, and still can't seem to figure out. I can't get a db connection using connection pools. I get the exception listed below, same as so many have previously, but nothing I've found seems to works. Below are my specs. Anyone with concrete advise/direction on how to get this working? Also, I noticed in many solutions the suggestion was made to edit the myapp.xml file located at CATALINA_HOME/conf/Catalina/localhost/. However, there is no myapp.xml in that directory on my server. Just 2 .xml's related to other applications and a manager.xml which I'm not sure what it's related to. OS: FC2 Tomcat 5.0.28 exception: org.apache.commons.dbcp.SWLNestedException: Cannot create JDBC driver class '' for connect URL 'null' WEB-INF web xml: code inserted AFTER all servlet mappings... the following shld be in web-app resource-ref descriptionMy Datasource/description res-ref-namejdbc/wms/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app !-- I am sure u have this right-- server xml(tried this with and without a Resource name)... The following shld be under Engine name=Standalone defaultHost=localhost debug=0 REplace Context path=/wms docBase=wms debug=0 reloadable=true with DefaultContext Resource name=jdbc/wms auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/wms parameter nameusername/name valuewhatever/value /parameter parameter namepassword/name valuewhatever/value /parameter parameter namedriverClassName/name valuecom.informix.jdbc.IfxDriver/value /parameter parameter nameurl/name valuejdbc:informix-sqli://foo.bar.com:somePort/dbName:INFORMIXSER VER=serverName/value /parameter /ResourceParams replace /Context with /DefaultContext !-- If this works them there is something wrong with your context. we shall figure that out later but first DefaultContext should work!! restart tommy after making changes. hope it works!! -- I have the following jars in my CATALINA_HONE/common/lib and I also tried putting the db driver and commons-collections, dbcp, and pool in my WEB-INF/lib with no success. They are all mode 644. ant.jar ant-launcher.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-el.jar commons-pool-1.2.jar ifxjdbc.jar (the necessary informix driver) jar.txt jasper-compiler.jar jasper-runtime.jar jsp-api.jar mysql-connector-java-3.0.15-ga-bin.jar naming-common.jar naming-factory.jar naming-java.jar naming-resources.jar servlet-api.jar On Fri, 8 Oct 2004 11:45:59 +0530, Atishay Kumar [EMAIL PROTECTED] wrote: hi, i am not sure but you may try downloading latest jar files for following froom tomcat site and try them out. copy the old jar files somewhere else and try using the latest jar files. 1) Commons Collections 2)Commons DBCP 3)Commons Pool On Thu, 7 Oct 2004 15:29:40 -0700, Eric Wulff [EMAIL PROTECTED] wrote: Except that the driver works for connecting if I'm not utilizing a connection pool, i.e., I am able to connect to the db
Database connection pooling
Hi, I'm attempting to integrate database connection pooling into an exisiting JSP-based web application. I'm running Tomcat 5.5.2 Server, with J2SE 1.5.0 and a MySQL database (version 11.18) accessed through the com.mysql.jdbc package. I've followed MySQL instructions from this page: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html I made the changes to server.xml and the web app's web.xml, changing variables to match the database name, user name and password of the correct database. I ensured the MySQL package was in common/lib/. My DAO objects now have constructors of the following form, which was adapted from code found online ('broadband' is the database name): private Connection myConn; private DataSource dataSource; /** * Constructs the data accessor using the connection pool * * @exception SQLException thrown for SQL errors */ public SearchDAO() throws SQLException { try { // retrieve datasource Context init = new InitialContext(); Context ctx = (Context) init.lookup(java:comp/env); dataSource = (DataSource) ctx.lookup(jdbc/broadband); // get connection synchronized (dataSource) { myConn = dataSource.getConnection(); } } catch (NamingException ex) { System.err.println( new SearchDAO: Cannot retrieve java:comp/env/jdbc/broadband: + ex); } catch (SQLException excep) { System.err.println( new SearchDAO: Could not get connection: + excep); } catch (Exception e) { System.err.println(new SearchDAO: + e); // System.out.println (In the catch block : ); //e.printStackTrace(); } } The constructor throws the following exception: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' The connect URL is present in server.xml and is correct for the database. My only guess at this point is that the howto document above asks for the Context tag to be added to server.xml between the example close Context and the first open Host tag, however there wasn't an example Context tag in server.xml and there appears to be a context.xml file in the same directory. I'm wondering if Contexts have moved to a different file in a recent version of Tomcat? It's just a wild guess (and I've no idea how to add the Context to context.xml as there's already a Context tag in there and no higher level tag around it). Any help would be greatly appreciated. Sorry if I'm wasting your time with an obvious or frequently asked question, I've googled and read quite a few documents, but I think I'm just at the 'stabbing in the dark' point and could do with guru guidance. Thanks, Nat. -- Nat Titman Developer MitchellConnerSearson 3-5 High Pavement The Lace Market Nottingham NG1 1HF Tel +44 (0)115 959 6455 Fax +44 (0)115 959 6456 Direct +44 (0)115 959 6462 www.choosemcs.co.uk Confidentiality: This e-mail and its attachments are intended for the above named only and may be confidential. If they have come to you in error you must take no action based on them, nor must you copy or show them to anyone; please reply to this e-mail and highlight the error. Security Warning: Please note that this e-mail has been created in the knowledge that Internet e-mail is not a 100% secure communications medium. We advise that you understand and observe this lack of security when e-mailing us. Viruses: Although we have taken steps to ensure that this e-mail and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]