From tomcat-user-return-124642-apmail-jakarta-tomcat-user-archive=jakarta.apache.org@jakarta.apache.org Mon Apr 11 13:38:12 2005 Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 12967 invoked from network); 11 Apr 2005 13:38:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Apr 2005 13:38:12 -0000 Received: (qmail 49114 invoked by uid 500); 11 Apr 2005 13:37:28 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 49059 invoked by uid 500); 11 Apr 2005 13:37:27 -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 48992 invoked by uid 99); 11 Apr 2005 13:37:26 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail.dsg.vertisinc.com (HELO mail.dsg.vertisinc.com) (63.103.126.135) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 11 Apr 2005 06:37:23 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Subject: RE: DBCP Please Help Get Working Properly Date: Mon, 11 Apr 2005 08:37:21 -0500 Message-ID: <34385CBC5E8E664EB0007814636AB36A0316D470@exchange1.dimensions.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: DBCP Please Help Get Working Properly Thread-Index: AcU+mP28pe+5bWhOSOes+ClLsgiumQAAd1bA From: "Scott Purcell" To: "Tomcat Users List" X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thank David for the below information. This makes some sense, and I will try and make the changes. But this of = course leads to a follow-up question. Why isn't there any decent = documentation to get the DBCP running in Tomcat. I am talking about a = simple example, that explains container versions, jsp versions, possibly = better ways to use then putting the connection into a JSP page. = Connecting in a JSP page is just plain dirty, I would like to connect in = some class where I can call connections from. Does this make sense? As I mentioned, I followed the example that comes with the documentation = for my 5.5 Tomcat that displays when you go to localhost. So, is there any good documentation that shows how to do this, step by = step? Thanks, Scott -----Original Message----- From: David Smith [mailto:dns4@cornell.edu] Sent: Monday, April 11, 2005 8:18 AM To: Tomcat Users List Subject: Re: DBCP Please Help Get Working Properly Ok, define 'no results'. In reality, the naming import isn't the only=20 thing that changed. Your web.xml file *looks* like 2.3 spec from what I=20 can see and you are using JSP 2.x spec syntax in your jsp. If you want=20 the JSP 2.x spec features, you need to declare your web.xml file for=20 servlet 2.4 spec. This should be up at the top of your web.xml (pasted=20 from the specification for servlet 2.4): Then just put all your servlet-mappings, etc., ... after that. The=20 taglib declarations need to be inside a element for the 2.4 = spec web.xml file too. That's how I'm guessing you have a 2.3 spec=20 web.xml file. The full spec can be found at=20 http://www.jcp.org/en/jsr/detail?id=3D154 --David Scott Purcell wrote: >Hello, > >I am trying to use the DBCP features of Tomcat 5.5.7. I created a = webapp named "testDB" and put it under $CATALINA_HOME/webapps/testDB. = Then I created a testDB.xml file under = $CATALINA_HOME/conf/Catalina/localhost/testDB.xml. > >// here it is > debug=3D"5" reloadable=3D"true" crossContext=3D"true"> > > maxActive=3D"100" maxIdle=3D"30" maxWait=3D"10000" > username=3D"javauser" password=3D"javadude" = driverClassName=3D"com.mysql.jdbc.Driver" > = url=3D"jdbc:mysql://localhost:3306/fritest?autoReconnect=3Dtrue"/> > > >I have been following the notes from:=20 >http://localhost/tomcat-docs/jndi-datasource-examples-howto.html > >I made sure I completed the rest of the tasks. >WEB-INF has the two tag locations, and the resource ref. >eg: > > > /WEB-INF/sql.tld > /WEB-INF/sql.tld > > > > > /WEB-INF/c.tld > /WEB-INF/c.tld > > > > DB Connection > jdbc/testDB > javax.sql.DataSource > Container > > >I finally hit my jsp page which is this: ><%@ taglib uri=3D"http://java.sun.com/jsp/jstl/sql" prefix=3D"sql" %> ><%@ taglib uri=3D"http://java.sun.com/jsp/jstl/core" prefix=3D"c" %> > > >select id, foo, bar from testdata > > > > > DB Test > > > >

Results

> =20 > > Foo ${row.foo}
> Bar ${row.bar}
>
> > > > > >And I get no results: > >Now I am pretty sure I have all configured. Because if I use a fallback = (Tomcat 4.1) code piece I had, I get results using the same settings: > >package foo; > >import javax.naming.*; >import javax.sql.*; >import java.sql.*; > >public class DBTest { > > String foo =3D "Not Connected"; > int bar =3D -1; > =20 > public void init() { > try{ > Context ctx =3D new InitialContext(); > if(ctx =3D=3D null )=20 > throw new Exception("Boom - No Context"); > > DataSource ds =3D=20 > (DataSource)ctx.lookup( > "java:comp/env/jdbc/testDB"); > > if (ds !=3D null) { > Connection conn =3D ds.getConnection(); > =20 > if(conn !=3D null) { > foo =3D "Got Connection "+conn.toString(); > Statement stmt =3D conn.createStatement(); > ResultSet rst =3D=20 > stmt.executeQuery( > "select id, foo, bar from testdata"); > while(rst.next()) { > System.out.println("next ...."); > foo=3Drst.getString(2); > bar=3Drst.getInt(3); > } > conn.close(); > } > } > }catch(Exception e) { > e.printStackTrace(); > } > } > > public String getFoo() { return foo; } > public int getBar() { return bar;} >} > >And using the above class works all day. > >The only difference I see is that the class using a "naming" import and = the jsp does not. Can anyone help. > > >Thanks, >Scott > > > > > > > > > >-----Original Message----- >From: David Smith [mailto:dns4@cornell.edu] >Sent: Friday, April 08, 2005 1:14 PM >To: Tomcat Users List >Subject: Re: Add Context Path, Tomcat 5.5.7 > > >Hi. > >Take a look at this for where to put elements: >http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html > >This is new with Tomcat 5.0 and is continued in Tomcat 5.5 > >--David > >Scott Purcell wrote: > > =20 > >>Hello, >> >>I am following the information here to add DBCP to my application. >>http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-example= s-howto.html >> >>I am reading to add the > >>Configure the JNDI DataSource in Tomcat by adding a declaration for = your resource to $CATALINA_HOME/conf/server.xml. >> >>Add this in between the tag of the examples context and the = tag closing the localhost definition. >> >> >> >>So cool, I opened up the server.xml, but do not see any existing = context or host tags in it. Here is my server.xml file. Does anyone know = where I put the Context for the DBCP stuff? Thanks, >> >>' >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > type=3D"org.apache.catalina.UserDatabase" >> description=3D"User database that can be updated and saved" >> = factory=3D"org.apache.catalina.users.MemoryUserDatabaseFactory" >> pathname=3D"conf/tomcat-users.xml" /> >> >> >> >> >> >> >> >> >> >> >> >> >port=3D"80" maxThreads=3D"150" minSpareThreads=3D"25" = maxSpareThreads=3D"75" >> enableLookups=3D"false" redirectPort=3D"8443" = acceptCount=3D"100" >> connectionTimeout=3D"20000" = disableUploadTimeout=3D"true" /> >> >> >> >> >> >> >> >> >> > enableLookups=3D"false" redirectPort=3D"8443" = protocol=3D"AJP/1.3" /> >> >> >> >> >> >> >> >> =20 >> =20 >> >> >> >> >> >> >> >> >> >> > resourceName=3D"UserDatabase"/> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > unpackWARs=3D"true" autoDeploy=3D"true" >> xmlValidation=3D"false" xmlNamespaceAware=3D"false"> >> >> =20 >> >> =20 >> =20 >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>Scott K Purcell | Developer | VERTIS |=20 >>555 Washington Ave. 4th Floor | St. Louis, MO 63101 |=20 >>314.588.0720 Ext:1320 | spurcell@vertisinc.com | = http://www.vertisinc.com =20 >> >>Vertis is the premier provider of targeted advertising, media, and=20 >>marketing services that drive consumers to marketers more effectively. = >> =20 >> >> >> >>=20 >> >> =20 >> > > > >--------------------------------------------------------------------- >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 > > =20 > --------------------------------------------------------------------- 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