Title: Datasources context ?

I have got this error
        Name java:comp is not bound in this Context

When I try the following code :
         try {
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDb");
            Connection conn = ds.getConnection();

            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery("SELECT prenom,nom FROM annuaire;");
            while (rs.next()) {
                out.println("<p>" + rs.getString("prenom"));
                out.println("&nbsp;" + rs.getString("nom"));
            }

            conn.close();
        } catch (Exception e) {
            out.print(e.getMessage());
        }
And the declarations
server.xml
            <Resource name="jdbc/TestDb" auth="CONTAINER"
                    type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/TestDb">
            <parameter><name>user</name><value>user</value></parameter>
            <parameter><name>password</name><value>passwd</value></parameter>
            <parameter><name>driverClassName</name>
              <value>org.gjt.mm.mysql.Driver</value></parameter>
            <parameter><name>driverName</name>
              <value>jdbc:mysql://localhost/test</value></parameter>
          </ResourceParams>
web.xml
<resource-ref>
    <description>Test database.</description>
    <res-ref-name>jdbc/TestDb</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>CONTAINER</res-auth>
</resource-ref>


What is wrong ???

Regards / Cordialement

Frederic Jacquet

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>


Reply via email to