3 Replies Latest reply on Oct 10, 2002 3:13 AM by Tung Dang

    registering datasources

    nd Newbie

      hi guys, i need some help.

      if i have a database where the connection to it was done
      using Sun's JdbcOdbcDriver (i.e. Connection = DriverManager.getConnection(
      "jdbc:odbc:testDB", "username", "password")),
      how do i register it into a datasource with a name "testDB"?
      what else should i do? in the ejb-jar.xml, how do i define in
      in the <resource-ref>?

      do i have to copy xml services (like for oracle, ms sql and others)?

      thanks very many!!!!!





        • 1. Re: registering datasources
          Sebastien Petrucci Newbie

          Hi,

          First, you really should not use the JdbcOdbcDriver bridge !! I'm not even sure that JBoss could support it...
          So find the JDBC driver for your DB and copy the jar(s)
          in your $JBOSS_HOME/server/<'default' most probably>/lib.
          Then check in the $JBOSS_HOME/docs/examples/jca and find the template that correspond to your DB.
          Make a copy of that file, edit it (you have to set the connection properties, the JNDI name, ...) and copy this file in your deploy folder. You should then see a message on the JBOSS logs. That's it.
          To access to datasource, then you just have to query JNDI (java:/<the jndi name you choose>).

          Good luck,
          Sebastien.

          • 2. Re: registering datasources
            nd Newbie

            hi!
            thanks for the response.
            i have some questions.
            if u run the default configuration in JBoss,
            is the hssql-service loaded up? (ie the hypersonic sql)?
            if its jndi is java:/DefaultDS how do i look it?
            when i look it up using

            ...
            Context lContext = new InitialContext();
            Object lObject = lContext.lookup("java:/DefaultDS");
            ...

            the result is:
            javax.naming.NameNotFoundException: DefaultDS not bound

            in my ejb-jar.xml
            i have added,

            <resource-ref>
            DataSource for the Hypersonic database
            <res-ref-name>java:/DefaultDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            </resource-ref>

            so how do i correctly look it up? thanks in advance!!