Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Abandoned Connections Not Working - Tomcat 4.1.24 - Oracle 8i

Abandoned Connections Not Working - Tomcat 4.1.24 - Oracle 8i

2003-10-17       - By Jonathan Reynolds

 Back
Reply:     1     2  

I am using Tomcat 4.1.24 on a Windows 2000 machine.  I have successfully set up
DBCP to provide a connection to my Oracle 8i database.  I am now trying to test
the removal of abandoned connections and it's not working according to the Data
Source HOW TO guide.  Can someone please help?

Here are my important files:

server.xml
-- ---- ---- ----

<Context className="org.apache.catalina.core.StandardContext Source code of org.apache.catalina.core.StandardContext" crossContext=
"false" reloadable="true" mapperClass="org.apache.catalina.core
.StandardContextMapper" useNaming="true" debug="0" swallowOutput="false"
privileged="false" displayName="Servlet Web App" wrapperClass="org.apache
.catalina.core.StandardWrapper" docBase="D:\Program Files\Apache Group\Tomcat 4
.1\webapps\servlets" cookies="true" path="/servlets" cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper Source code of org.apache.catalina.util.CharsetMapper">
  <Resource name="jdbc/SMSOraclePool" scope="Shareable" type="javax.sql
.DataSource" auth="Container" description="SMS Oracle Pool"/>
  <ResourceParams name="jdbc/SMSOraclePool">
     <parameter>
        <name>factory</name>
        <value>org.apache.commons.dbcp.BasicDataSourceFactory Source code of org.apache.commons.dbcp.BasicDataSourceFactory</value>
     </parameter>
     <parameter>
        <name>url</name>
        <value>jdbc:oracle:thin:@(protected):1521:pearson</value>
     </parameter>
     <parameter>
        <name>password</name>
        <value>xxx</value>
     </parameter>
     <parameter>
        <name>maxActive</name>
        <value>2</value>
     </parameter>
     <parameter>
        <name>maxWait</name>
        <value>-1</value>
     </parameter>
     <parameter>
        <name>driverClassName</name>
        <value>oracle.jdbc.driver.OracleDriver</value>
     </parameter>
     <parameter>
        <name>username</name>
        <value>xxx</value>
     </parameter>
     <parameter>
        <name>maxIdle</name>
        <value>1</value>
     </parameter>
     <parameter>
        <name>removeAbandoned</name>
        <value>true</value>
     </parameter>
     <parameter>
        <name>removeAbandonedTimeout</name>
        <value>5</value>
     </parameter>
     <parameter>
        <name>logAbandoned</name>
        <value>true</value>
     </parameter>
  </ResourceParams>
</Context>

web.xml
-- ---- ---- --

 <resource-ref>
     <description>SMS Oracle Connection</description>
     <res-ref-name>jdbc/SMSOraclePool</res-ref-name>
     <res-type>javax.sql.DataSource Source code of javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
 </resource-ref>

Code Example
-- ---- ---- ---- ---

import javax.servlet.http.HttpServlet Source code of javax.servlet.http.HttpServlet;
import javax.servlet.ServletException Source code of javax.servlet.ServletException;
import javax.servlet.RequestDispatcher Source code of javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig Source code of javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest Source code of javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse Source code of javax.servlet.http.HttpServletResponse;
import java.io.IOException Source code of java.io.IOException;
import java.sql.Connection Source code of java.sql.Connection;
import javax.sql.DataSource Source code of javax.sql.DataSource;
import java.sql.*;
import javax.naming.InitialContext Source code of javax.naming.InitialContext;
import javax.naming.Context Source code of javax.naming.Context;

public class PoolTest extends HttpServlet
{
 /**
  *See doGet()
  **/
 public void doPost(HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException
 {
   doGet(req,res);
 }


 /**
  *  Determine which version response is desired, and forward to appropriate
Authentication
  *  servlet.  If no version is sent, assume that an Authentication 1.0
response is desired.
  **/
 public void doGet (HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException
 {

   try
   {
       /* Context initContext = new InitialContext();
       Context envContext  = (Context)initContext.lookup("java:/comp/env");
       DataSource ds = (DataSource)envContext.lookup("jdbc/SMSOraclePool");
       */
       
       //Obtain our environment naming context
       Context initCtx = new InitialContext();

       DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc
/SMSOraclePool");

       Connection conn1 = ds.getConnection();
       System.out.println("Pool Test Servlets: Connection 1 received");
       Connection conn2 = ds.getConnection();
       System.out.println("Pool Test Servlets: Connection 2 received");
       Connection conn3 = ds.getConnection();
       System.out.println("Pool Test Servlets: Connection 3 received");

   }
   catch(Exception ex)
   {
     ex.printStackTrace(System.out);
   }
 }
}



When I run the code above, I see the following printouts:

Pool Test Servlets: Connection 1 received
Pool Test Servlets: Connection 2 received



I don't see the third printout, which is what I excpect.  However, after 5
seconds, the connections are not returned to the pool and see NO stackTrace to
the logs or to the console.  Any help would be most appreciated.  Thanks.

Jonathan


©2008 junlu.com - Jax Systems, LLC, U.S.A.