1 Reply Latest reply on Aug 24, 2001 2:08 PM by Mick Jordan

    Getting wrong database connection

    Mick Jordan Newbie

      I believe that I followed the instructions in the configuration exactly regarding the setup of a new datasource to an Oracle database using the thin driver. However, at run-time, the connection is being made to the Hypersonic database. This is very weird and I would expect a failure instead if I had mis-configured something. This is the simple Account example from J2EE RI and I have had this working on J2EE RI and BEA:

      So the code opens the connection thus:

      DataSource ds = (DataSource) ic.lookup(java:comp/env/jdbc/AccountDB);
      con = ds.getConnection();
      DatabaseMetaData md = con.getMetaData();
      System.out.println("MetaData is " + md.toString());

      The relevant portion of the ejb-jar.xml is (unchanged from RI release)


      The jboss.xml contains a jndi redirect:


      (I tried java:/OracleDB also with no effect)

      and the jboss.jcml file contains the following


      plus the driver addition, which is working as the startup trace shows the driver loading. At run-time the metdata from the connection is printed as:

      [AccountBean] MetaData is org.hsql.jdbcDatabaseMetaData@4aa2db

      followed by a failure to find the ACCOUNT table (since it doesn't exist in the HyperSonic database).

      I'm hoping someone can see some obvious fault here as I am stumped as to explain the behavior.

        • 1. Re: Getting wrong database connection
          Mick Jordan Newbie

          So, I'll answer my own question. I had the <resource-ref> outside the tag in the jboss.xml file. This wasn't being checked during XML parsing because I hadn't referenced the DTD.

          It also turned out to be important to have the java:/ in:


          Leaving java:/ out did not bind the name but at least I got an error when I tried to look it up.

          The reason I got the Hypersonic driver initially is presumably because of the following default behavior which is specified in the jboss.dtd file:

          The mapping between the "xml name" and the "runtime jndi name" is given in
          a resource-manager section. If not, and if the datasource is of type
          javax.sql.DataSource, jboss will look for a javax.sql.DataSource in the jndi