You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Eric Wulff <ew...@gmail.com> on 2004/10/06 23:08:53 UTC
connection pooling
Hi all, I have gone over some of the tomcat docs and googled errors
but there is SO much information covering JNDI and Datasources... and
I'm hoping I don't have to be a JNDI/Datasource and XML guru just to
set up db connections via connection pool.
My situation is this...
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 jdbc driver is in the correct place
...CATALINA
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Capturing HTML using Tomcat 4
Posted by "Luke (Terry) Vanderfluit" <lu...@chipcity.com.au>.
Hi,
I'm not sure if this is what you mean.
You could simply run the following code to capture the output of the
jsp.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
String htmlText;
URL u = new
URL("http://www.server.com:8080/application/some.jsp");
BufferedReader htmlPage =
new BufferedReader(new InputStreamReader(
u.openStream()));
while((htmlText = htmlPage.readLine()) != null){
System.out.println(htmlText);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regards,
Luke
On Thu, 2004-10-07 at 07:39, David Wall wrote:
> I've been looking through archives and such for examples of how to capture
> the HTML output from a given JSP programmatically so I can archive or do
> other things with that HTML. For example, we might do this to record the
> text of an agreement that was displayed to a user, in which a JSP generated
> the agreement HTML page. The pages may be generated from either HTTP GET or
> POST.
>
> It would be nice to perhaps just have a servlet "include" the response from
> a JSP, passing along the GET/POST request to that JSP, but then have the
> servlet capture the JSP's response in a string for processing/storage.
> O'Reilly has a caching servlet that may help, but I was wondering if anybody
> had come out with an elegant way to do this.
>
> Thanks,
> David
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
--
========================
Luke (Terry) Vanderfluit
Mobile: 0421 276 282
========================
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Capturing HTML using Tomcat 4
Posted by Ben Souther <bs...@fwdco.com>.
> Could a filter do the job?
Yes, it most certainly could.
If your interested, I wrote one and packaged into a war file.
http://ben.souther.us/capture.war
It should be enough to get you started.
On Wed, 2004-10-06 at 19:23, Mike Curwen wrote:
> Could a filter do the job?
>
> response wrapping always seems scarey to me, but it should be possible to
> wrap all the requests for a given URL space (so for example, anything that
> might conveniently fall under the /agreement/* URL space), and after your
> call to doChain, you can extract and persist a copy of the HTML response.
>
> No touching the existing pages, you only need to map the correct URLs (and
> there can be multiple ones, of course).
>
>
> > -----Original Message-----
> > From: David Wall [mailto:d.wall@computer.org]
> > Sent: Wednesday, October 06, 2004 6:03 PM
> > To: 'Tomcat Users List'
> > Subject: Re: Capturing HTML using Tomcat 4
> >
> >
> > That's not as "nice" only because most of the pages to be
> > captured are JSPs, and converting the JSP to a servlet for
> > this purpose would defeat much of the beauty of JSPs. I saw
> > a listing for using a "capture JSP tag" at
> > http://www.jguru.com/faq/view.jsp?EID=304022 that seems kind
> > of interesting. Of course, if this works well, it would only
> > work on JSPs in which the tag could be placed.
> >
> > David
> >
> > ----- Original Message -----
> > From: "Robert Harper" <ro...@iat-cti.com>
> > To: "'Tomcat Users List'" <to...@jakarta.apache.org>;
> > "'David Wall'" <d....@computer.org>
> > Sent: Wednesday, October 06, 2004 3:20 PM
> > Subject: RE: Capturing HTML using Tomcat 4
> >
> >
> > > One way is to write a servlet that builds the html and before you
> > > finish
> > with
> > > the response, save the text into a table and then send the response.
> > >
> > > Robert S. Harper
> > > 801.265.8800 ex. 255
> > > > -----Original Message-----
> > > > From: David Wall [mailto:d.wall@computer.org]
> > > > Sent: Wednesday, October 06, 2004 4:10 PM
> > > > To: tomcat-user@jakarta.apache.org
> > > > Subject: Capturing HTML using Tomcat 4
> > > >
> > > > I've been looking through archives and such for examples of how to
> > capture
> > > > the HTML output from a given JSP programmatically so I
> > can archive
> > > > or do other things with that HTML. For example, we might
> > do this to
> > > > record
> > the
> > > > text of an agreement that was displayed to a user, in which a JSP
> > generated
> > > > the agreement HTML page. The pages may be generated from either
> > > > HTTP
> > GET or
> > > > POST.
> > > >
> > > > It would be nice to perhaps just have a servlet "include" the
> > > > response
> > from
> > > > a JSP, passing along the GET/POST request to that JSP,
> > but then have
> > > > the servlet capture the JSP's response in a string for
> > > > processing/storage. O'Reilly has a caching servlet that may help,
> > > > but I was wondering if
> > anybody
> > > > had come out with an elegant way to do this.
> > > >
> > > > Thanks,
> > > > David
> > > >
> > > >
> > > >
> > --------------------------------------------------------------------
> > > > -
> > > > 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
RE: Capturing HTML using Tomcat 4
Posted by Ben Souther <bs...@fwdco.com>.
> Could a filter do the job?
Yes, it most certainly could.
If your interested, I wrote one and packaged into a war file.
It prints all the servlet output of the index.jsp page from the ROOT
application that ships with tomcat to standard out.
http://ben.souther.us/capture.war
It should be enough to get you started.
On Wed, 2004-10-06 at 19:23, Mike Curwen wrote:
> Could a filter do the job?
>
> response wrapping always seems scarey to me, but it should be possible to
> wrap all the requests for a given URL space (so for example, anything that
> might conveniently fall under the /agreement/* URL space), and after your
> call to doChain, you can extract and persist a copy of the HTML response.
>
> No touching the existing pages, you only need to map the correct URLs (and
> there can be multiple ones, of course).
>
>
> > -----Original Message-----
> > From: David Wall [mailto:d.wall@computer.org]
> > Sent: Wednesday, October 06, 2004 6:03 PM
> > To: 'Tomcat Users List'
> > Subject: Re: Capturing HTML using Tomcat 4
> >
> >
> > That's not as "nice" only because most of the pages to be
> > captured are JSPs, and converting the JSP to a servlet for
> > this purpose would defeat much of the beauty of JSPs. I saw
> > a listing for using a "capture JSP tag" at
> > http://www.jguru.com/faq/view.jsp?EID=304022 that seems kind
> > of interesting. Of course, if this works well, it would only
> > work on JSPs in which the tag could be placed.
> >
> > David
> >
> > ----- Original Message -----
> > From: "Robert Harper" <ro...@iat-cti.com>
> > To: "'Tomcat Users List'" <to...@jakarta.apache.org>;
> > "'David Wall'" <d....@computer.org>
> > Sent: Wednesday, October 06, 2004 3:20 PM
> > Subject: RE: Capturing HTML using Tomcat 4
> >
> >
> > > One way is to write a servlet that builds the html and before you
> > > finish
> > with
> > > the response, save the text into a table and then send the response.
> > >
> > > Robert S. Harper
> > > 801.265.8800 ex. 255
> > > > -----Original Message-----
> > > > From: David Wall [mailto:d.wall@computer.org]
> > > > Sent: Wednesday, October 06, 2004 4:10 PM
> > > > To: tomcat-user@jakarta.apache.org
> > > > Subject: Capturing HTML using Tomcat 4
> > > >
> > > > I've been looking through archives and such for examples of how to
> > capture
> > > > the HTML output from a given JSP programmatically so I
> > can archive
> > > > or do other things with that HTML. For example, we might
> > do this to
> > > > record
> > the
> > > > text of an agreement that was displayed to a user, in which a JSP
> > generated
> > > > the agreement HTML page. The pages may be generated from either
> > > > HTTP
> > GET or
> > > > POST.
> > > >
> > > > It would be nice to perhaps just have a servlet "include" the
> > > > response
> > from
> > > > a JSP, passing along the GET/POST request to that JSP,
> > but then have
> > > > the servlet capture the JSP's response in a string for
> > > > processing/storage. O'Reilly has a caching servlet that may help,
> > > > but I was wondering if
> > anybody
> > > > had come out with an elegant way to do this.
> > > >
> > > > Thanks,
> > > > David
> > > >
> > > >
> > > >
> > --------------------------------------------------------------------
> > > > -
> > > > 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
RE: Capturing HTML using Tomcat 4
Posted by Mike Curwen <g_...@globallyboundless.com>.
oops. I meant ".. it should be possible to **filter** all the requests..."
:o
> -----Original Message-----
> From: Mike Curwen [mailto:g_dev9xq@globallyboundless.com]
> Sent: Wednesday, October 06, 2004 6:24 PM
> To: 'Tomcat Users List'; 'David Wall'
> Subject: RE: Capturing HTML using Tomcat 4
>
>
> Could a filter do the job?
>
> response wrapping always seems scarey to me, but it should be
> possible to wrap all the requests for a given URL space (so
> for example, anything that might conveniently fall under the
> /agreement/* URL space), and after your call to doChain, you
> can extract and persist a copy of the HTML response.
>
> No touching the existing pages, you only need to map the
> correct URLs (and there can be multiple ones, of course).
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Capturing HTML using Tomcat 4
Posted by Mike Curwen <g_...@globallyboundless.com>.
Could a filter do the job?
response wrapping always seems scarey to me, but it should be possible to
wrap all the requests for a given URL space (so for example, anything that
might conveniently fall under the /agreement/* URL space), and after your
call to doChain, you can extract and persist a copy of the HTML response.
No touching the existing pages, you only need to map the correct URLs (and
there can be multiple ones, of course).
> -----Original Message-----
> From: David Wall [mailto:d.wall@computer.org]
> Sent: Wednesday, October 06, 2004 6:03 PM
> To: 'Tomcat Users List'
> Subject: Re: Capturing HTML using Tomcat 4
>
>
> That's not as "nice" only because most of the pages to be
> captured are JSPs, and converting the JSP to a servlet for
> this purpose would defeat much of the beauty of JSPs. I saw
> a listing for using a "capture JSP tag" at
> http://www.jguru.com/faq/view.jsp?EID=304022 that seems kind
> of interesting. Of course, if this works well, it would only
> work on JSPs in which the tag could be placed.
>
> David
>
> ----- Original Message -----
> From: "Robert Harper" <ro...@iat-cti.com>
> To: "'Tomcat Users List'" <to...@jakarta.apache.org>;
> "'David Wall'" <d....@computer.org>
> Sent: Wednesday, October 06, 2004 3:20 PM
> Subject: RE: Capturing HTML using Tomcat 4
>
>
> > One way is to write a servlet that builds the html and before you
> > finish
> with
> > the response, save the text into a table and then send the response.
> >
> > Robert S. Harper
> > 801.265.8800 ex. 255
> > > -----Original Message-----
> > > From: David Wall [mailto:d.wall@computer.org]
> > > Sent: Wednesday, October 06, 2004 4:10 PM
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: Capturing HTML using Tomcat 4
> > >
> > > I've been looking through archives and such for examples of how to
> capture
> > > the HTML output from a given JSP programmatically so I
> can archive
> > > or do other things with that HTML. For example, we might
> do this to
> > > record
> the
> > > text of an agreement that was displayed to a user, in which a JSP
> generated
> > > the agreement HTML page. The pages may be generated from either
> > > HTTP
> GET or
> > > POST.
> > >
> > > It would be nice to perhaps just have a servlet "include" the
> > > response
> from
> > > a JSP, passing along the GET/POST request to that JSP,
> but then have
> > > the servlet capture the JSP's response in a string for
> > > processing/storage. O'Reilly has a caching servlet that may help,
> > > but I was wondering if
> anybody
> > > had come out with an elegant way to do this.
> > >
> > > Thanks,
> > > David
> > >
> > >
> > >
> --------------------------------------------------------------------
> > > -
> > > 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
Re: Capturing HTML using Tomcat 4
Posted by David Wall <d....@computer.org>.
That's not as "nice" only because most of the pages to be captured are JSPs,
and converting the JSP to a servlet for this purpose would defeat much of
the beauty of JSPs. I saw a listing for using a "capture JSP tag" at
http://www.jguru.com/faq/view.jsp?EID=304022 that seems kind of interesting.
Of course, if this works well, it would only work on JSPs in which the tag
could be placed.
David
----- Original Message -----
From: "Robert Harper" <ro...@iat-cti.com>
To: "'Tomcat Users List'" <to...@jakarta.apache.org>; "'David Wall'"
<d....@computer.org>
Sent: Wednesday, October 06, 2004 3:20 PM
Subject: RE: Capturing HTML using Tomcat 4
> One way is to write a servlet that builds the html and before you finish
with
> the response, save the text into a table and then send the response.
>
> Robert S. Harper
> 801.265.8800 ex. 255
> > -----Original Message-----
> > From: David Wall [mailto:d.wall@computer.org]
> > Sent: Wednesday, October 06, 2004 4:10 PM
> > To: tomcat-user@jakarta.apache.org
> > Subject: Capturing HTML using Tomcat 4
> >
> > I've been looking through archives and such for examples of how to
capture
> > the HTML output from a given JSP programmatically so I can archive or do
> > other things with that HTML. For example, we might do this to record
the
> > text of an agreement that was displayed to a user, in which a JSP
generated
> > the agreement HTML page. The pages may be generated from either HTTP
GET or
> > POST.
> >
> > It would be nice to perhaps just have a servlet "include" the response
from
> > a JSP, passing along the GET/POST request to that JSP, but then have the
> > servlet capture the JSP's response in a string for processing/storage.
> > O'Reilly has a caching servlet that may help, but I was wondering if
anybody
> > had come out with an elegant way to do this.
> >
> > Thanks,
> > David
> >
> >
> > ---------------------------------------------------------------------
> > 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
RE: Capturing HTML using Tomcat 4
Posted by Robert Harper <ro...@iat-cti.com>.
One way is to write a servlet that builds the html and before you finish with
the response, save the text into a table and then send the response.
Robert S. Harper
801.265.8800 ex. 255
> -----Original Message-----
> From: David Wall [mailto:d.wall@computer.org]
> Sent: Wednesday, October 06, 2004 4:10 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Capturing HTML using Tomcat 4
>
> I've been looking through archives and such for examples of how to capture
> the HTML output from a given JSP programmatically so I can archive or do
> other things with that HTML. For example, we might do this to record the
> text of an agreement that was displayed to a user, in which a JSP generated
> the agreement HTML page. The pages may be generated from either HTTP GET or
> POST.
>
> It would be nice to perhaps just have a servlet "include" the response from
> a JSP, passing along the GET/POST request to that JSP, but then have the
> servlet capture the JSP's response in a string for processing/storage.
> O'Reilly has a caching servlet that may help, but I was wondering if anybody
> had come out with an elegant way to do this.
>
> Thanks,
> David
>
>
> ---------------------------------------------------------------------
> 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
Capturing HTML using Tomcat 4
Posted by David Wall <d....@computer.org>.
I've been looking through archives and such for examples of how to capture
the HTML output from a given JSP programmatically so I can archive or do
other things with that HTML. For example, we might do this to record the
text of an agreement that was displayed to a user, in which a JSP generated
the agreement HTML page. The pages may be generated from either HTTP GET or
POST.
It would be nice to perhaps just have a servlet "include" the response from
a JSP, passing along the GET/POST request to that JSP, but then have the
servlet capture the JSP's response in a string for processing/storage.
O'Reilly has a caching servlet that may help, but I was wondering if anybody
had come out with an elegant way to do this.
Thanks,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: connection pooling
Posted by Eric Wulff <ew...@gmail.com>.
Hi Atishay, added your suggestion to the server.xml. While it is not
the fix, I do have a different error listing. Is this a clue to you?
Eric
current last listing of stack trace...
Caused by: java.lang.NullPointerException at
com.informix.jdbc.IfxDriver.checkURL(IfxDriver.java:473) at
com.informix.jdbc.IfxDriver.acceptsURL(IfxDriver.java:297) at
java.sql.DriverManager.getDriver(DriverManager.java:232) at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
... 28 more
original last listing of stack trace...
java.sql.SQLException: No suitable driver at
java.sql.DriverManager.getDriver(DriverManager.java:243) at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
On Thu, 7 Oct 2004 19:17:14 +0530, Atishay Kumar
<at...@gmail.com> wrote:
> On Wed, 6 Oct 2004 14:37:58 -0700, Eric Wulff <ew...@gmail.com> wrote:
> > 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 <Context> (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:
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <!DOCTYPE web-app
> > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > "http://java.sun.com/dtd/web-app_2_3.dtd">
> > <web-app>
> > <servlet>
> > <servlet-name>Test Connection Pooling</servlet-name>
> > <servlet-class>TestConnectionPooling</servlet-class>
> > </servlet>
> >
> > <servlet-mapping>
> > <servlet-name>Test Connection Pooling</servlet-name>
> > <url-pattern>/testConnectionPooling</url-pattern>
> > </servlet-mapping>
> >
> > <resource-ref>
> > <res-ref-name>jdbc/test_connect</res-ref-name>
> > <res-type>javax.sql.DataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> > </web-app>
> >
> > server.xml <Context>:
> > <Context path="/testConnectionPooling"
> > docBase="testConnectionPooling" debug="0" reloadable="true">
>
> <Resource name="jdbc/test_connection" auth="Container"
> type="javax.sql.DataSource"/>
> is missing
>
> > <ResourceParams name="jdbc/test_connect">
> > <parameter>
> > <name>username</name>
> > <value>informix</value>
> > </parameter>
> > <parameter>
> > <name>password</name>
> > <value>informix</value>
> > </parameter>
> > <parameter>
> > <name>driverClassName</name>
> > <value>com.informix.jdbc.IfxDriver</value>
> > </parameter>
> > <parameter>
> > <name>url</name>
> > <value>jdbc:informix-sqli://url:port/dbName:INFORMIXSERVER=serverName</value>
> > </parameter>
> > </ResourceParams>
> > </Context>
> >
> > .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 ("<HTML><HEAD><TITLE>Test Connection
> > Pooling</TITLE></HEAD><BODY>");
> > out.println("<H1>Customer Name Query</H1>");
> >
> > try {
> > synchronized(dataSource) {
> > connection = dataSource.getConnection();
> > }
> > out.println("<br>");
> > out.println("<strong>Loaded informix driver successfully via
> > server.xml.</strong>" +
> > "Now attempting db connection.");
> > out.println("<br>");
> > 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("<br>");
> > while(results.next()) {
> > out.println("<tr><td>" + results.getString("blah") + "</td></tr>");
> > }
> > } catch (Exception ex) {
> > out.println("<br>");
> > out.println("Exception: " + ex);
> > if(ex instanceof SQLException) {
> > SQLException sqlex = (SQLException) ex;
> > out.println("<br>");
> > out.println("SQL state: "+sqlex.getSQLState()+"<BR>");
> > out.println("<br>");
> > out.println("Error code: "+sqlex.getErrorCode()+"<BR>");
> > out.println("<br><br>");
> > sqlex.printStackTrace(out);
> > out.println("<br><br>");
> > }
> > }
> > finally {
> > try { connection.close(); } catch (Exception ex) {}
> > }
> > out.println ("</BODY></HTML>");
> >
> >
> > }
> > }
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
>
> --
> :)
> 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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: connection pooling
Posted by Atishay Kumar <at...@gmail.com>.
On Wed, 6 Oct 2004 14:37:58 -0700, Eric Wulff <ew...@gmail.com> wrote:
> 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 <Context> (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:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
> <servlet>
> <servlet-name>Test Connection Pooling</servlet-name>
> <servlet-class>TestConnectionPooling</servlet-class>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>Test Connection Pooling</servlet-name>
> <url-pattern>/testConnectionPooling</url-pattern>
> </servlet-mapping>
>
> <resource-ref>
> <res-ref-name>jdbc/test_connect</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
> </web-app>
>
> server.xml <Context>:
> <Context path="/testConnectionPooling"
> docBase="testConnectionPooling" debug="0" reloadable="true">
<Resource name="jdbc/test_connection" auth="Container"
type="javax.sql.DataSource"/>
is missing
> <ResourceParams name="jdbc/test_connect">
> <parameter>
> <name>username</name>
> <value>informix</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>informix</value>
> </parameter>
> <parameter>
> <name>driverClassName</name>
> <value>com.informix.jdbc.IfxDriver</value>
> </parameter>
> <parameter>
> <name>url</name>
> <value>jdbc:informix-sqli://url:port/dbName:INFORMIXSERVER=serverName</value>
> </parameter>
> </ResourceParams>
> </Context>
>
> .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 ("<HTML><HEAD><TITLE>Test Connection
> Pooling</TITLE></HEAD><BODY>");
> out.println("<H1>Customer Name Query</H1>");
>
> try {
> synchronized(dataSource) {
> connection = dataSource.getConnection();
> }
> out.println("<br>");
> out.println("<strong>Loaded informix driver successfully via
> server.xml.</strong>" +
> "Now attempting db connection.");
> out.println("<br>");
> 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("<br>");
> while(results.next()) {
> out.println("<tr><td>" + results.getString("blah") + "</td></tr>");
> }
> } catch (Exception ex) {
> out.println("<br>");
> out.println("Exception: " + ex);
> if(ex instanceof SQLException) {
> SQLException sqlex = (SQLException) ex;
> out.println("<br>");
> out.println("SQL state: "+sqlex.getSQLState()+"<BR>");
> out.println("<br>");
> out.println("Error code: "+sqlex.getErrorCode()+"<BR>");
> out.println("<br><br>");
> sqlex.printStackTrace(out);
> out.println("<br><br>");
> }
> }
> finally {
> try { connection.close(); } catch (Exception ex) {}
> }
> out.println ("</BODY></HTML>");
>
>
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
--
:)
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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
connection pooling
Posted by Eric Wulff <ew...@gmail.com>.
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 <Context> (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:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>Test Connection Pooling</servlet-name>
<servlet-class>TestConnectionPooling</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test Connection Pooling</servlet-name>
<url-pattern>/testConnectionPooling</url-pattern>
</servlet-mapping>
<resource-ref>
<res-ref-name>jdbc/test_connect</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
server.xml <Context>:
<Context path="/testConnectionPooling"
docBase="testConnectionPooling" debug="0" reloadable="true">
<ResourceParams name="jdbc/test_connect">
<parameter>
<name>username</name>
<value>informix</value>
</parameter>
<parameter>
<name>password</name>
<value>informix</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.informix.jdbc.IfxDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:informix-sqli://url:port/dbName:INFORMIXSERVER=serverName</value>
</parameter>
</ResourceParams>
</Context>
.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 ("<HTML><HEAD><TITLE>Test Connection
Pooling</TITLE></HEAD><BODY>");
out.println("<H1>Customer Name Query</H1>");
try {
synchronized(dataSource) {
connection = dataSource.getConnection();
}
out.println("<br>");
out.println("<strong>Loaded informix driver successfully via
server.xml.</strong>" +
"Now attempting db connection.");
out.println("<br>");
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("<br>");
while(results.next()) {
out.println("<tr><td>" + results.getString("blah") + "</td></tr>");
}
} catch (Exception ex) {
out.println("<br>");
out.println("Exception: " + ex);
if(ex instanceof SQLException) {
SQLException sqlex = (SQLException) ex;
out.println("<br>");
out.println("SQL state: "+sqlex.getSQLState()+"<BR>");
out.println("<br>");
out.println("Error code: "+sqlex.getErrorCode()+"<BR>");
out.println("<br><br>");
sqlex.printStackTrace(out);
out.println("<br><br>");
}
}
finally {
try { connection.close(); } catch (Exception ex) {}
}
out.println ("</BODY></HTML>");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org