Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 25980 invoked from network); 6 Oct 2004 21:52:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 6 Oct 2004 21:52:03 -0000 Received: (qmail 5390 invoked by uid 500); 6 Oct 2004 21:51:34 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 5311 invoked by uid 500); 6 Oct 2004 21:51:33 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 5298 invoked by uid 99); 6 Oct 2004 21:51:33 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [202.37.93.67] (HELO HONDANET.HONDA.CO.NZ) (202.37.93.67) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 06 Oct 2004 14:51:30 -0700 Subject: Re: connection pooling To: "Tomcat Users List" X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 Message-ID: From: jthompson@honda.co.nz Date: Thu, 7 Oct 2004 10:49:15 +1300 X-MIMETrack: Serialize by Router on HONDA01/XB/HONDA(Release 6.0.2CF1|June 9, 2003) at 10/07/2004 10:49:19 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Please ignore my last post - it's wrong. (Answered before verifying). John Thompson |---------+----------------------------> | | Eric Wulff | | | | | | | | | 07/10/2004 10:37 | | | AM | | | Please respond to| | | "Tomcat Users | | | List" | | | | |---------+----------------------------> >--------------------------------------------------------------------------------------------------------------| | | | To: tomcat-user@jakarta.apache.org | | cc: | | Subject: connection pooling | >--------------------------------------------------------------------------------------------------------------| I have gone over some of the tomcat docs and googled errors but there is SO much information covering JNDI, connection pooling, and Datasources. Can someone review the info below and consult or point me in the right direction? Although I feel I'm missing something obvious, I can't find out what's wrong with my set-up. thx Eric System: Tomcat 5 on Fedora Core 2 connecting to a db on an Informix Dynamic Server 9.4 on Windows Server -I am able to connect to my db via typical JDBC DriverManager.getConnection(). This leads me to believe that my informix jdbc driver is in the correct place... CATALINA_HOME/common/lib -I have a Context set up in my server.xml per examples in a text tutorial I'm referencing Below listed... -errors -web.xml -server.xml (minus connection actual values) -.java exception/errors: -Exception: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' SQL state: null Error code: 0 -stack trace reveals this, but I can't see why since I have the driver in the correct directory... java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773) web.xml: Test Connection Pooling TestConnectionPooling Test Connection Pooling /testConnectionPooling jdbc/test_connect javax.sql.DataSource Container server.xml : username informix password informix driverClassName com.informix.jdbc.IfxDriver url jdbc:informix-sqli://url:port/dbName:INFORMIXSERVER=serverName .java: import java.io.*; import java.sql.*; // -Must import javax.naming use JNDI which is required to implement data // resource references and hence connection pooling. import javax.naming.*; import javax.sql.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; public class TestConnectionPooling extends HttpServlet { private DataSource dataSource; public void init(ServletConfig config) throws ServletException { try { Context init = new InitialContext(); // don't know what the 'java:comp/env' refers to Context ctx = (Context) init.lookup("java:comp/env"); // I know "jdbc/conversion must match the web.xml res-ref-name of the web.xml but don't know what the path really refers to dataSource = (DataSource) ctx.lookup("jdbc/test_connect"); } catch (NamingException ex) { throw new ServletException("Cannot retrieve java:comp/env/jdbc/test_connect",ex); } } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); Connection connection = null; out.println ("Test Connection Pooling"); out.println("

Customer Name Query

"); try { synchronized(dataSource) { connection = dataSource.getConnection(); } out.println("
"); out.println("Loaded informix driver successfully via server.xml." + "Now attempting db connection."); out.println("
"); PreparedStatement pstmt = connection.prepareStatement("SELECT blah FROM blah blah"); ResultSet results = pstmt.executeQuery(); if (!results.next()) { throw new SQLException("No data returned for some reason"); } out.println("
"); while(results.next()) { out.println("" + results.getString("blah") + ""); } } catch (Exception ex) { out.println("
"); out.println("Exception: " + ex); if(ex instanceof SQLException) { SQLException sqlex = (SQLException) ex; out.println("
"); out.println("SQL state: "+sqlex.getSQLState()+"
"); out.println("
"); out.println("Error code: "+sqlex.getErrorCode()+"
"); out.println("

"); sqlex.printStackTrace(out); out.println("

"); } } finally { try { connection.close(); } catch (Exception ex) {} } out.println (""); } } --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org