tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frederic Monclar <frederic.monc...@profium.com>
Subject Re: Datasources context ?
Date Fri, 15 Feb 2002 16:17:19 GMT
May be you have defined at a wrong place your resource in your
server.xml file.
Fred.


> "Jacquet, Frederic" wrote:
> 
> 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:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message