3 Replies Latest reply on Jan 4, 2005 6:03 PM by Frank Langelage

    jdbc not bound

    Barun Kumar Das Newbie

      hi all,

      i am using Eclipse as my IDE, JBoss as my AS, Postgres as my Database server. when i am trying to connect database from my action class its get connected but when i'm using EJB and trying to connect i get error "javax.naming.NameNotFoundException: jdbc not bound". i'm having class to get connection. code is as simple as

      Context ctx = new InitialContext();
      DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/myCoreDS");
      Connection conn = ds.getConnection();

      Please help me cause i've spent lots of time and i have not got any thing useful.

      Thanking you in advance.

        • 1. Re: jdbc not bound
          Mario Laubscher Newbie


          Have you deployed your Postgres - data source definition?

          Here a sample...

          Data Source definition File:
          Note that the name of the data source definition file must end with -ds.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <!-- ===================================================================== -->
          <!-- -->
          <!-- JBoss Server Configuration -->
          <!-- -->
          <!-- ===================================================================== -->
          <!-- $Id: postgres-ds.xml,v 1.3 2004/09/15 14:37:40 loubyansky Exp $ -->
          <!-- ==================================================================== -->
          <!-- Datasource config for Postgres -->
          <!-- ==================================================================== -->
           <!-- sql to call when connection is created
           <new-connection-sql>some arbitrary sql</new-connection-sql>
           <!-- sql to call on an existing pooled connection when it is obtained from pool
           <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
           <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
           <type-mapping>PostgreSQL 7.2</type-mapping>

          • 2. Re: jdbc not bound
            Viktor Ivanov Newbie

            Did you try
            DataSource ds = (DataSource) ctx.lookup("java:jdbc/myCoreDS");

            • 3. Re: jdbc not bound
              Frank Langelage Master

              The jndi-name of your datasource is combined of "java:" and the jndi-name from the -ds.xml file.
              Take a look at jmx-console/JNDIView to see what's available.