Tomcat is something of which I both understand and am mystified by at the same time. It has confounded me and been a breeze! "and she's always a woman to me...."!
I am working on an application in which I want to use Tomcat to manage my connection pooling. I am getting the following error:
javax.servlet.ServletException: Name
jdbc is not bound in this Context
here is my server.xml:
<Context path="/FamilyViolence" docBase="roller" debug="0">
<Resource name="jdbc/ywstats" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/ywstats">
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/ywstats?autoReconnect=true</value>
</parameter>
<parameter><name>maxActive</name><value>25</value></parameter>
<parameter><name>maxWait</name><value>100</value></parameter>
<parameter><name>username</name><value>tboyce</value></parameter>
<parameter><name>password</name><value>4guneyeh</value></parameter>
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
</ResourceParams>
</Context>
MY Web.xml file:
<resource-ref>
<res-ref-name>"jdbc/ywstats"</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
My
jsp code:
<%
Vector v_cnty=new Vector();
ResultSet rs_cnty = null;
DataSource pool;
InitialContext intCtx = new InitialContext();
DataSource ds = (DataSource)intCtx.lookup("java:comp/env/jdbc/ywstats");
Connection conn = ds.getConnection();
java.sql.Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select county_name from county_info");
while (rset.next())
{
v_cnty.addElement(rset.getString(0));
}
Any help would be greatly appreciated and I'd, of course, love to win a copy of your book!!!