6 Replies Latest reply on Aug 13, 2008 9:38 AM by badam571

    how to configure JBOSS to connect to two databases schema?

      I have an application using sybase db. the application connects to 2 dabase schems: qtx_ss and qtx_sx.

      Each one has multiple tables ..

      the application knows in advance which one to connect to. but the question is how to configure the jboss, when the application passes the name of the specific datasource, it will get the right connection?


      I tried to configure two sybase-ds.xml files with different names, but what about the other config files?

      Is the approach above is right or there is an alternative solutions?
      Is any resources speaking about this?

      Best Regards

      badam571

        • 1. Re: how to configure JBOSS to connect to two databases schem
          peterj

           

          badam571 wrote:
          I tried to configure two sybase-ds.xml files with different names


          That is the correct approach. Your app would then select the datasource, and thus the database, based its JNDI name.

          badam571 wrote:
          what about the other config files


          What config files?

          • 2. Re: how to configure JBOSS to connect to two databases schem

            Hi PeterJ

            thank you for the reassuring and prompt response.

            the other config files

            standardjbosscmp-jdbc.xml

            standardjaws.xml

            jboss-login.xml

            I am interested in knowing about: standardjbosscmp-jdbc.xml

            should I add another defaults tag for the new datasource in standardjbosscmp-jdbc.xml or how I will accommodate the new datasource in this file. This config file continuouly generate an errror like this:

            --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
            ObjectName: jboss.jdbc:service=metadata
            State: FAILED
            Reason: org.jboss.deployment.DeploymentException: Invalid XML: file=file:/C:/j
            boss-4.0.4.GA/server/default/conf/standardjbosscmp-jdbc.xml; - nested throwable:
            (org.xml.sax.SAXParseException: The content of element type "jbosscmp-jdbc" mus
            t match "(defaults?,enterprise-beans?,relationships?,dependent-value-classes?,ty
            pe-mappings?,entity-commands?,user-type-mappings?,reserved-words?)".)
            Depends On Me:
            jboss.jdbc:service=metadata,datasource=DefaultDS
            jboss.jdbc:service=metadata,datasource=SybaseDS
            jboss.jdbc:service=metadata,datasource=SybaseDB


            at org.jboss.deployment.MainDeployer.checkIncompleteDeployments(MainDepl
            oyer.java:1367)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:774)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:755)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
            java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
            sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
            er.java:155)
            at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
            at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
            or.java:133)
            at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
            at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
            BeanOperationInterceptor.java:142)
            at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
            at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
            java:264)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
            at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
            at $Proxy5.deploy(Unknown Source)
            at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
            at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
            at org.jboss.Main.boot(Main.java:200)
            at org.jboss.Main$1.run(Main.java:464)
            at java.lang.Thread.run(Thread.java:595)
            11:53:09,363 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0
            -8080


            Best Regards

            badam571

            • 3. Re: how to configure JBOSS to connect to two databases schem
              peterj

              Only one "defaults" entry is allowed, after all, that is what it is - the default.

              Are you using EJB 2.x entity beans to store the data in the database? If so, then are you storing some entities in one database and others in another? If not, then standardjbosscmp-jdbc.xml is not used an you can ignore it. Also, if you are not using EJB 2.x entity beans, what are you using to store data? Hibernate? JDBC?

              • 4. Re: how to configure JBOSS to connect to two databases schem

                Hi PerterJ

                I am using JDBC to connect to the db. Per the guide documentations, I should have to configure the file: standardjbosscmp-jdbc.xml in order to handle the datasource correctly.

                what do you think?

                Best Regards

                badam571

                • 5. Re: how to configure JBOSS to connect to two databases schem
                  peterj

                  The standardjbosscmp-jdbc.xml file is for use with Container-Manager Persistence, one of the features of EJB which has the container (JBosAS, in this case) manage the persistence of entity beans.

                  If you are using JDBC calls to manage the data in the database, you can ignore that file.

                  • 6. Re: how to configure JBOSS to connect to two databases schem

                    PeterJ

                    Good point. I will try to ignore it altogether.

                    thank you for your help.


                    Best Regards

                    badam571