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 thing that changed. Your web.xml file *looks* like 2.3 spec from what I can see and you are using JSP 2.x spec syntax in your jsp. If you want the JSP 2.x spec features, you need to declare your web.xml file for servlet 2.4 spec. This should be up at the top of your web.xml (pasted from the specification for servlet 2.4): >// here it is > debug="5" reloadable="true" crossContext="true"> > > maxActive="100" maxIdle="30" maxWait="10000" > username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver" > url="jdbc:mysql://localhost:3306/fritest?autoReconnect=true"/> > > >I have been following the notes from: >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="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> ><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> > > >select id, foo, bar from testdata > > > > > DB Test > > > >

Results

> > > 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 = "Not Connected"; > int bar = -1; > > public void init() { > try{ > Context ctx = new InitialContext(); > if(ctx == null ) > throw new Exception("Boom - No Context"); > > DataSource ds = > (DataSource)ctx.lookup( > "java:comp/env/jdbc/testDB"); > > if (ds != null) { > Connection conn = ds.getConnection(); > > if(conn != null) { > foo = "Got Connection "+conn.toString(); > Statement stmt = conn.createStatement(); > ResultSet rst = > stmt.executeQuery( > "select id, foo, bar from testdata"); > while(rst.next()) { > System.out.println("next ...."); > foo=rst.getString(2); > bar=rst.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: > > > >>Hello, >> >>I am following the information here to add DBCP to my application. >>http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-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="org.apache.catalina.UserDatabase" >> description="User database that can be updated and saved" >> factory="org.apache.catalina.users.MemoryUserDatabaseFactory" >> pathname="conf/tomcat-users.xml" /> >> >> >> >> >> >> >> >> >> >> >> >> >port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" >> enableLookups="false" redirectPort="8443" acceptCount="100" >> connectionTimeout="20000" disableUploadTimeout="true" /> >> >> >> >> >> >> >> >> >> > enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > resourceName="UserDatabase"/> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > unpackWARs="true" autoDeploy="true" >> xmlValidation="false" xmlNamespaceAware="false"> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>Scott K Purcell | Developer | VERTIS | >>555 Washington Ave. 4th Floor | St. Louis, MO 63101 | >>314.588.0720 Ext:1320 | spurcell@vertisinc.com | http://www.vertisinc.com >> >>Vertis is the premier provider of targeted advertising, media, and >>marketing services that drive consumers to marketers more effectively. >> >> >> >> >> >> >> >> > > > >--------------------------------------------------------------------- >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