11 Replies Latest reply on Mar 14, 2003 12:01 PM by gary_kephart

    JBoss newbie: Connecting to JDBC

    gary_kephart

      First off, I've tried this in WebLogic and got it to work. Now, I'm trying to get it to work in JBoss.

      Problem:
      I'm getting a "table not found" error.

      I'm connecting to an MS Access database using JDBC.

      My code says:
      this.dataSource = (DataSource)ic.lookup("java:comp/env/jdbc/bahiawebDB");

      The ejb-jar.xml says:
      <resource-ref>
      <res-ref-name>jdbc/bahiawebDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      jboss.xml says:
      <resource-ref>
      <res-ref-name>jdbc/bahiawebDB</res-ref-name>
      <resource-name>jdbc:odbc:bahiawebDB</resource-name>
      </resource-ref>

      and I modified msaccess-service.xml, replacing all occurrences of "InsightDB" with "bahiawebDB". I then put that file in my bahiaweb.jar as well as the default/deploy directory (just to be sure).

      So what gives?

        • 1. Re: JBoss newbie: Connecting to JDBC
          gary_kephart

          One step closer...

          Note to self: always throw "new EJBException(ex)" and not "new EJBException(ex.toString())". Helps stack trace.

          Now I get this exception line in the log file:
          at org.hsqldb.jdbcPreparedStatement.executeQuery(jdbcPreparedStatement.java:133)

          Looks like it's going to a Hyperion db instead of mine. Why?
          Looks like it's bound to DefaultDS, if hsqldb-service.xml is any clue:
          DefaultDS

          The server.log file shows
          2003-01-29 16:12:56,141 INFO [org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.DefaultDS] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/DefaultDS'

          Am I mapping bahiawebDB to JBoss LocalTransaction JDBC Wrapper? Back to searching for an answer.

          • 2. Re: JBoss newbie: Connecting to JDBC
            gary_kephart

            Finally got it working. See attachment

            • 3. Re: JBoss newbie: Connecting to JDBC
              goldrimtang

              Thanks for your info, it's been very helpful !!

              • 4. Re: JBoss newbie: Connecting to JDBC
                ndijkstra

                I used your access datasource configuration as a sample but when i deploy it, i get a warn message:
                09:41:09,699 WARN [ServiceController] jboss.jca:service=LocalTxDS,name=pedidosDB does not implement
                any Service methods

                • 5. Re: JBoss newbie: Connecting to JDBC
                  gary_kephart

                  Could you post your -service.xml file?

                  • 6. Re: JBoss newbie: Connecting to JDBC
                    ndijkstra

                    Despite the warning i get, the datasource works fine. The only problem i have is that i have to manually start the service through the administrator.
                    Why is it that i don't automatically get the datasource binded to de JNDI????
                    Please, i need help!!

                    • 7. Re: JBoss newbie: Connecting to JDBC
                      gary_kephart

                      > Despite the warning i get, the datasource works fine.
                      > The only problem i have is that i have to manually
                      > start the service through the administrator.
                      > Why is it that i don't automatically get the
                      > datasource binded to de JNDI????
                      > Please, i need help!!

                      Hmm. I've never had to start the service from the console. Having the service work even though there is a warning may not mean anything. There still may be a problem in the -service.xml file that's causing your problem. Please post it.

                      • 8. Re: JBoss newbie: Connecting to JDBC
                        ndijkstra

                        This is the code of the file msaccess-service at
                        <jboss_home>/server/default/deploy.
                        I took the file from the examples directory, so it should work correctly.



                        <depends optional-attribute-name="ManagedConnectionFactoryName">

                        pedidosDB


                        <config-property name="ConnectionURL" type="java.lang.String">jdbc:odbc:pedidosDB</config-property>
                        <config-property name="DriverClass" type="java.lang.String">sun.jdbc.odbc.JdbcOdbcDriver</config-property>


                        <depends optional-attribute-name="OldRarDeployment">
                        jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper



                        <depends optional-attribute-name="ManagedConnectionPool">

                        0
                        50
                        5000
                        15
                        ByNothing


                        <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
                        <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager
                        java:/TransactionManager
                        jboss.jca:service=RARDeployer


                        • 9. Re: JBoss newbie: Connecting to JDBC
                          gary_kephart

                          Well, you were right, the service file works fine. I looked through my log files, and my service file gives the same message.
                          So you say that the service has to be started through the admin console, right? What error message did you get when you didn't do that?

                          • 10. Re: JBoss newbie: Connecting to JDBC
                            ndijkstra

                            I had no error message.
                            When requesting a secured page, no matter what login/password y entered, nothing happened. It just wasn't getting the connection to de datasource.

                            Now, i changed my JBoss to 3.0.4 and eveything works fine. Only God kowns why.

                            Thanks

                            • 11. Re: JBoss newbie: Connecting to JDBC
                              gary_kephart

                              Best of luck, then!