You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Richey, Clark" <Cl...@aquilent.com> on 2003/06/25 21:34:21 UTC

Name java:comp is not bound in this Context

I am having difficuties getting a Tomcat datasource set up. I keep getting the error: Name java:comp is not bound in this Context.
Here is the relevant portion of my server.xml:
<Resource name="jdbc/jugaccino"     auth="Servlet"    type="javax.sql.DataSource"/>
  <ResourceParams name="jdbc/jugaccino">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>maxActive</name>
      <value>100</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <value>30</value>
    </parameter>
    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>
    <parameter>
     <name>username</name>
     <value>xxx</value>
  </parameter>
    <parameter>
     <name>password</name>
     <value>xxx</value>
    </parameter>
    <parameter>
       <name>driverClassName</name>
       <value>org.gjt.mm.mysql.Driver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:mysql://localhost/jugaccino?autoReconnect=true</value>
    </parameter>
  </ResourceParams>

In web.xml I have the following:
 <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/jugaccino</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Application</res-auth>
  </resource-ref>

The following JSP is a simple test which gives me the error described:
<body>
<%@page import="javax.naming.*"%>
<%@page import="javax.sql.*"%>
<%@page import="java.sql.*"%>
<% 
Context initCtx = new InitialContext();
     DataSource ds =
            (DataSource)initCtx.lookup("java:comp/env/jdbc/jugaccino");
      if (ds != null) {
        Connection conn = ds.getConnection();
        if(conn != null)  {
            foo = "Got Connection "+conn.toString();
            Statement stmt = conn.createStatement();
            ResultSet rst =
                stmt.executeQuery(
                  "select * from downloadcount");
            if(rst.next()) {
               foo=rst.getString("downloads");
            }
            conn.close();
        }
      }
%>

Thanks for your help!


Clark D. Richey, Jr.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org