2 Replies Latest reply on Nov 27, 2002 10:18 PM by Chris Bailey

    jndi lookup

    Brandon Vallade Newbie

      I have a utility class that my EJB's use to obtain a db connection from a pool. I currently have it working using:
      Context initctx = new InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource)initctx.lookup("java:/MyDS");

      What do I have to do in order to be able to look it up as
      Context initctx = new InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource)initctx.lookup("java:comp/env/jdbc/MyDS");

      In my jboss.xml I have:
      But this does not do the trick.


        • 1. Re: jndi lookup
          Luc Vu Newbie

          I know this is a little late to reply, but this might help whoever is reading this.

          What you need to do is this:


          • 2. Re: jndi lookup
            Chris Bailey Newbie

            Nope, doesn't seem to work, only the "java:/" works, trying to map to
            the more portable "java:comp/env..." as you suggest fails, either not
            finding the name in the context, or, even worse, apparently using the
            wrong driver (maybe one of the developers would be interested in that)

            C:\eclipse\workspace\Converter>ant run-junit
            [junit] driverName=HSQL Database Engine Driver
            [junit] OK (3 tests)

            [junit] .driverName=Mark Matthews' MySQL Driver
            [junit] OK (3 tests)

            And the few relevant lines in the files



            DataSource dataSource = (DataSource) ic.lookup("java:comp/env/jdbc/ODCSDS");
            return dataSource.getConnection().getMetaData().getDriverName();