1 Reply Latest reply on Jul 11, 2003 11:07 AM by juhalindfors

    Oracle Connection from EJB bean

    Arup Sarkar Newbie

      Hi I have created a test ejb and trying to connect to oracle from bean, but I am getting the following error.

      "16:35:03,474 INFO [STDOUT] javax.ejb.EJBException: Unable to connect to databas
      e. jdbc not bound"

      the following is the code.

      private void makeConnection() {

      System.out.println("CustomerBean makeConnection");

      try {
      InitialContext ic = new InitialContext();
      DataSource ds = (DataSource) ic.lookup(CodedNames.MY_DATABASE);
      con = ds.getConnection();
      } catch (Exception ex) {
      throw new EJBException("Unable to connect to database. " +
      } // makeConnection

      basically CodedNames.MY_DATABASE is as follows:

      public interface CodedNames {

      //public static final String SIEBEL_DATABASE = "java:comp/env/jdbc/OracleDS";
      public static final String MY_DATABASE = "java:/OracleDS";


      I have modified the oracle-service.xml.

      Can someone please advise what piece I am missing.

      Any help is greatly appreciated.


        • 1. Re: Oracle Connection from EJB bean

          Use the bean's private ENC lookup name java:comp/env/jdbc/OracleDS rather than the direct java: namespace. Make sure you have the correct resource reference mapping in your ejb-jar.xml for the lookup name and that you correctly map this to the physical lookup name (java:OracleDS) in your jboss.xml.

          Also make sure whatever physical JNDI lookup name you use actually shows up in the JNDIView on jmx-console.