tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wang, Hansen" <>
Subject RE: first jdbc tomcat application
Date Thu, 23 Feb 2006 18:44:02 GMT
If you are using tomcat5, do not use ResourceParams. Instead, define
those params as attribute of <Resource>, as this:
 <Resource name="jdbc/WroxTC5" auth="Container"
	username="xyz" ...

-----Original Message-----
From: David McMinn [] 
Sent: Thursday, February 23, 2006 9:20 AM
Subject: first jdbc tomcat application

I'm stepping through the example Professional Apache Tomcat 5 book by
Wrox in Chapter 14 - I have set up the mysql database and confirmed it
works and set up the tomcat server and confirmed that I can see my
index.jsp page. When I try to go to
  I get a standard The page cannot be displayed page.
  I've included all my steps below. Anyone that can help is most
appreciated. Thanks in advance.....Dave
  Steps I have done
  1) Created a DB called everycitizen and a table called test with a
column called pk. Created user everyuser w/ a password and granted
Select privileges to that user.
  2) Copied the mysql-connector-java-3.1.12-bin.jar into
  3)Added the following to the $CATALINA_HOME/conf/server.xml just
before the </Host tag>. Password is blotted out.
  <!-- added by DM 2/22/2006 -->
  <Resource name="jdbc/WroxTC5" auth="Container"
  <ResourceParams name="jdbc/WroxTC5">
   ; <value>20</value>

  4) Added the following to the
$CATALINA_HOME/webapps/jsp-examples/WEB-INF web.xml file at the bottom
just before the </web-app> entry after the last env-entry. 

  5) Added the JDBCTest.jsp file and the errorpg.jsp file to
$CATALINA_HOME/webapps/jsp-examples/wroxjdbc directory. I created the
wroxjdbc folder. The JDBC Test is:
  <%@ page errorPage="errorpg.jsp"
     javax.naming.Context" %>
  <h1>JDBC JNDI Resource Test</h1>
  InitialContext initCtx = new InitialContext();
  DataSource ds =
  Connection conn = ds.getConnection();
  Statement stmt = conn.createStatement();
  ResultSet rset = stmt.executeQuery("select * from test;");
  <table width = '600' border='1'>
    <th align='left'>XXXX</th>
   while (
    <tr><td> <%=rset.getInt(0)%></td></tr>
   <% } 
  and the errorpg is:
  <%@ page isErrorPage="true" %>
  <h1> An error has occurred </h1>
  <%= exception.getMessage() %>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message