Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 21670 invoked from network); 2 Jul 2004 18:28:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Jul 2004 18:28:35 -0000 Received: (qmail 46453 invoked by uid 500); 2 Jul 2004 18:27:39 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 46391 invoked by uid 500); 2 Jul 2004 18:27:38 -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 46364 invoked by uid 99); 2 Jul 2004 18:27:38 -0000 X-ASF-Spam-Status: No, hits=0.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,FROM_ENDS_IN_NUMS X-Spam-Check-By: apache.org Received: from [144.160.112.18] (HELO tspsmtp8.sbc.com) (144.160.112.18) by apache.org (qpsmtpd/0.27.1) with ESMTP; Fri, 02 Jul 2004 11:27:36 -0700 Received: from sbc.com (localhost [127.0.0.1]) by tspsmtp8.sbc.com (8.12.10/8.12.10) with ESMTP id i62IRIfO012923; Fri, 2 Jul 2004 13:27:19 -0500 (CDT) Received: from txdlls2msghub01.ITServices.sbc.com (txdlls2msghub01.itservices.sbc.com [155.179.130.51]) by tspsmtp8.sbc.com (8.12.10/8.12.10) with ESMTP id i62IRArE012827; Fri, 2 Jul 2004 13:27:15 -0500 (CDT) Received: from txdlls2msgusr13.ITServices.sbc.com ([155.179.119.58]) by txdlls2msghub01.ITServices.sbc.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 2 Jul 2004 13:27:11 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: How to use oracle pool instead of using DBCP pool? Date: Fri, 2 Jul 2004 13:27:10 -0500 Message-ID: <5C6859B23203524195A81F6EED34F46D0C11DA@txdlls2msgusr13.itservices.sbc.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: How to use oracle pool instead of using DBCP pool? Thread-Index: AcRgW1cpi1vzne3xSYat7RD7VsGKIQABNG7A From: "SANTOS, DANIEL (SBCSI)" To: "Tomcat Users List" , X-OriginalArrivalTime: 02 Jul 2004 18:27:11.0516 (UTC) FILETIME=[30CF25C0:01C46062] X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I use a method similar to this as well. I don't use a servlet listener = however. I use a javax.servlet.ServletContextListener instead however. = I store the jdbd url in my web.xml also as a context-param (I just just = cram it all into one paramater however) and put the pool as an attribute = of the Context. Here is the shorthand for that below: public void contextInitialized(ServletContextEvent sce) { String dbUrl =3D sce.getServletContext().getInitParameter("dbUrl") OracleDataSource pool =3D new OracleDataSource(); pool.setURL(dbUrl); sce.getServletContext().setAttribute("dbConnectionPool", pool); } and I have my classes12.zip (renamed to .jar) in my WEB-INF/lib folder -----Original Message----- From: David Short [mailto:dshort@san.rr.com] Sent: Friday, July 02, 2004 12:40 PM To: 'Tomcat Users List' Subject: RE: How to use oracle pool instead of using DBCP pool? I'm sure there's another way. This is how I use it. You can extract = the connection pool logic and embed in your framework. -----Original Message----- From: Claudio Carvalho [mailto:claudio@powerlogic.com.br] Sent: Friday, July 02, 2004 10:33 AM To: Tomcat Users List; dshort@san.rr.com Subject: Re: How to use oracle pool instead of using DBCP pool? Hi Davi, Thanks, but I'm trying to solve this problem without changing my J2EE framework... using JNDI,etc... Do you know any other approach? Claudio Carvalho. ----- Original Message ----- From: "David Short" To: "'Tomcat Users List'" Sent: Friday, July 02, 2004 1:55 PM Subject: RE: How to use oracle pool instead of using DBCP pool? > Try this. > > Here's how I do it using Struts on W2K. Modify names and paths to = suit your > needs. > > Upon startup, a listener servlet (ResourceManagerListener) is called = (See > tag in the included web.xml source). > > The listener servlet will create the connection pool based on your = web.xml > parameters (See ResourceManagerListener.java). Once started, the = listener > servlet initializes an application scope variable (appDataSource), = which > when called from your servlets/JSPs will return a DB DataSource object = (DB > connection). > > = -------------------------------------------------------------------------= - -- > --------------------------- > > In your main servlet: > > try > { > DataSource ds =3D (DataSource) > getServlet().getServletContext().getAttribute("appDataSource"); > xxxProcess =3D new xxxProcessBean(); > xxxInfo =3D new xxxInfoBean(); > xxxProcess.setDataSource(ds); > xxxInfo =3D xxxProcess.getUser(userName, customerId); > } > > In your process bean: > > public class xxxProcessBean implements Serializable > { > private DataSource dataSource; > > /** > * Sets the dataSource property value. > */ > public void setDataSource(DataSource dataSource) > { > this.dataSource =3D dataSource; > } > > > public xxxInfoBean getUser(String userName, String customerId) > throws SQLException > { > // Get the user info from the database > Connection conn =3D dataSource.getConnection(); > xxxInfoBean xxxResult =3D null; > > try > { > xxxResult =3D getUserName(userName, customerId, conn); // = Execute > actual SQL statement. > } > > finally > { > try > { > conn.close(); > conn =3D null; > } > > catch (SQLException e) > {} // Ignore > > return xxxResult; > > = -------------------------------------------------------------------------= - -- > --------------------------- > > Change MachineNameHere to your machine name. > Change OracleSIDHere to your DB SID. > Change DBUserNameHere to your DB username. > Change DBPasswordHere to your DB password > Change ApplicationNameHere to a meaningful application designator. > Change xxx to your object name. > > Copy Oracle's classes12.zip and nls_charset12.zip files (should live = in > C:\OraHome\jdbc\lib) to C:\Tomcat\common\lib. Depending on the = version of > Tomcat, you may need to rename the .zip files to .jar. > > > I'll let you read/learn about Struts on your own. > > Hoe this helps. > > Dave > > = -------------------------------------------------------------------------= - -- > --------------------------- > web.xml > > > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com//dtd/web-app_2_3.dtd"> > > > > > javax.servlet.jsp.jstl.fmt.fallbackLocale > en > > > > > > > > jdbcURL > > jdbc:oracle:oci8:@OracleSIDHere > > > > user > DBUserNameHere > > > > password > DBPasswordHere > > > > maxLimit > 50 > > > > > minLimit > 10 > > > > > accessControl > > com.ApplicationNameHere.servlets.AccessControlFilter > > > loginPage > /jsp/login.jsp > > > > > accessControl > /protected/* > > > > > com.ApplicationNameHere.servlets.ResourceManagerListener > > > > > > action > = org.apache.struts.action.ActionServlet > 1 > > > > > errorDispatcher > > com.ApplicationNameHere.servlets.ErrorDispatcherServlet let-class> > > errorPage > /jsp/error/errorpage.jsp?debug=3Dlog > > > > > > action > *.do > > > > errorDispatcher > /errorDispatcher > > > > > 1 > > > > > java.lang.Throwable > /errorDispatcher > > > > 500 > /errorDispatcher > > > > java.sql.SQLException > /errorDispatcher > > > > jdbc/ApplicationNameHere > javax.sql.DataSource > Container > > > > > = -------------------------------------------------------------------------= - -- > --------------------------- > ResourceManagerListener.java > package com.ApplicationNameHere.servlets; > > import javax.servlet.*; > import javax.servlet.http.*; > > import oracle.jdbc.pool.*; > > import javax.naming.*; > import javax.sql.*; > > import java.sql.*; > import java.math.*; > import java.util.*; > > /** > * This class manages the DataSource resource for an application, > * creating an Oracle DataSource with pooling capabilities > * and makes it available when the application starts and removes it > * when the application is shut down. > * > * @author David Short, Relational Concepts, Inc. > * @version David Short 01/10/2004 initial release. > */ > public class ResourceManagerListener implements ServletContextListener > { > private OracleConnectionCacheImpl ds =3D null; > private Context ctx =3D null; > > public void contextInitialized(ServletContextEvent sce) > { > ServletContext application =3D sce.getServletContext(); > > /* > * Get the JDBC URL, user, password and limits from the web.xml > * context init parameters > */ > String jdbcURL =3D application.getInitParameter("jdbcURL"); > String user =3D application.getInitParameter("user"); > String password =3D application.getInitParameter("password"); > String minLimit =3D application.getInitParameter("minLimit"); > String maxLimit =3D application.getInitParameter("maxLimit"); > > try > { > ds =3D new OracleConnectionCacheImpl(); > ds.setURL(jdbcURL); > ds.setUser(user); > ds.setPassword(password); > ds.setMinLimit(Integer.parseInt(minLimit)); > ds.setMaxLimit(Integer.parseInt(maxLimit)); > } > catch (Exception e) > { > application.log("Failed to create data source: " + = e.getMessage()); > } > > /* > Initialize the database connection pool. > */ > try > { > ctx =3D new InitialContext(); > ctx.lookup("java:comp/env/jdbc/ApplicationNameHere"); > } > catch (Exception e) > { > application.log("Failed to create database connection pool: " + > e.getMessage()); > } > > application.setAttribute("appDataSource", ds); > } > > public void contextDestroyed(ServletContextEvent sce) > { > ServletContext application =3D sce.getServletContext(); > application.removeAttribute("appDataSource"); > // Close the connections in the DataSource > try > { > ds.close(); > } > catch (java.sql.SQLException e) > {} > > ds =3D null; > } > } > > -----Original Message----- > From: Tim Funk [mailto:funkman@joedog.org] > Sent: Friday, July 02, 2004 8:36 AM > To: Tomcat Users List > Subject: Re: How to use oracle pool instead of using DBCP pool? > > > Nope. (Oracle's technical support /bulletin boards might be of more = help) > > -Tim > > Claudio Carvalho wrote: > > > Hi Tim, > > > > I'm looking for an alternative directly on the application server, > something > > like putting an "oracle-pool" jar into tomcat/common/lib directory, = have > you > > heard anything like that? > > > > Claudio Carvalho. > > > > ----- Original Message ----- > > From: "Tim Funk" > > To: "Tomcat Users List" > > Sent: Friday, July 02, 2004 10:52 AM > > Subject: Re: How to use oracle pool instead of using DBCP pool? > > > > > > > >>An alternative is to look at the DBCP java-docs. Cast your = Connection to a > >>DBCP's ppoled connection class (or approrpiate). That class has a = method > >>called getDelegate() which returns the real connection from Oracle. = Then > > > > cast > > > >>that to the appropriate Oracle class. > >> > >>-Tim > >> > >>Claudio Carvalho wrote: > >> > >> > >>>Cl=E1udio CarvalhoHi, > >>> > >>>I'm trying to get the CLOB working in my application and I'm having > > > > problems > > > >>>with the Connection, so, does anybody knows how to use in Tomcat 5 = the > >>>oracle pool instead of using the DBCP pool? > >>> > >> > > --------------------------------------------------------------------- > 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 > > --------------------------------------------------------------------- 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 --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org