1 Reply Latest reply on Oct 7, 2008 1:25 PM by peterj

    How to name my JNDI(progress Connection pool) and call it?


      I want to setup connection pooling in JBossAS for Progress database.
      I am not able to acess this JNDI? can anybody point out he problem in my code or in my xml file?

      Are there any good practices that should be followed in
      1) naming the XML file, and how does jboss locate particular JNDI
      2) how to name the <jndi-name> in the XML file
      3) how to lookup the jndi using java code?
      I got confused seeing various codes
      one says use "java:comp/name"
      other says "java:name"
      Seeing at my code can anybody explain how should I call the jndi?


      I have a web-ds.xml file deployed in server/all/deploy

      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ===================================================================== -->
      <!-- JBoss Server Configuration -->
      <!-- $Id: qadWeb-ds.xml 63175 2007-05-21 16:26:06Z rrajesh $ -->
      <!-- Datasource config for Progress 9.1 -->




      <!-- The maximum connections in a pool/sub-pool -->

      <!-- sql to call on an existing pooled connection when it is obtained from pool-->
      <check-valid-connection-sql>SELECT COUNT(1) FROM pub.zzad_ctrl</check-valid-connection-sql>


      <!-- HSQL DB benefits from prepared statement caching -->

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->

      <type-mapping>PostgreSQL 7.2</type-mapping>


      And the code to acess it
      private Connection connectToDatabase(String name) throws ErpProxyDaoException, SQLException{

      Connection con=null;
      Context ctx = null;
      DataSource ds = null;
      logger.info("before loading the datasource");
      logger.info("the database I'm connecting to is :" + name);
      ctx = new InitialContext();
      ds = (DataSource) ctx.lookup("java:/" + name);
      logger.info("After loading the datasource: " + ds);
      }catch(Exception e){
      throw new ErpProxyDaoException("to throw NamingException -- ", e);
      return con;

        • 1. Re: How to name my JNDI(progress Connection pool) and call i

          According to your web-ds.xml file, you can look up the datasource using the name "":

          ds = (DataSource) ctx.lookup("java:/web");

          if that doesn't work, try "java:/web" (even I get confused as to whether the slash is required).

          If you want to look up the datasource using your naming context (that is, via "java:/comp/env"), then you need to add the following to WEB-INF/web.xml:


          and the following to WEB-INF/jboss-web.xml:


          Then in your code use:

          ds = (DataSource) ctx.lookup("java:/comp/env/web1");

          I changed the name in the code to 'web1' so that you could see how that maps to the web.xml, which in turn maps to the jboss-web.xml, which in turn changes the name to simply 'web' which then matches the name in the *-ds.xml file.