Title: RE: Datasources context ?

In fact I just reading the JNDI Howto and try to set up the thing for the very first time for JDBC access

Someone (Mark) seems to have the same kind of problem with oracle ;(
Where can I  find a working test sample ?

-----Original Message-----
From: Remy Maucherat [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 6:47 PM
To: Tomcat Users List
Subject: Re: 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());
>         }

Well, the big questions are:
- where is that code fragment located ?
- are you modifying the context classloader ?

To end up with the right JNDI context, Catalina uses context classloader
associations. So if you get the error you're getting, it means that the CL
association is not the one it should be. There were a few bugs caused
because in some places, it wasn't set properly (for example, you can look at
bug 5330).

Remy


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

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


Reply via email to