2 Replies Latest reply on Mar 15, 2005 8:36 PM by gberish

    Why Can't I Use Two MySQL Databases?

    gberish

      Hi;

      I configured JbBoss to use MySql and created two databases therein:
      "jbossdb"
      "go"

      I'd really like to have JBoss use "jbossdb" for its jms_message, jms_roles, jms_subscriptions, jms_transactions and jms_users tables.

      And I'd like JBoss to use "go" for my bean persistance tables: games, members, plays, names.

      Here is what I tried, but my bean tables still end up in jbossdb.

      Can anyone point me to my problem?

      mysql-ds.xml

      <datasources>
       <local-tx-datasource>
       <jndi-name>DefaultDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       ...
       </local-tx-datasource>
       <local-tx-datasource>
       <jndi-name>GoDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/go</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       ...
       </local-tx-datasource>
      </datasources>
      ejb-jar.xml
      <ejb-jar>
       ...
       <enterprise-beans>
       <!-- MemberBean -->
       <entity>
       ...
       <ejb-name>MemberEJB</ejb-name>
       <resource-ref>
       <description/>
       <res-ref-name>GoDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       ...
       </resource-ref>
       </entity>
       </enterprise-beans>
      </ejb-jar>
      jboss.xml
      <jboss>
       <enterprise-beans>
       <!-- MemberBean -->
       <entity>
       <ejb-name>MemberEJB</ejb-name>
       <local-jndi-name>ejb/MemberLocalHome</local-jndi-name>
       <resource-ref>
       <res-ref-name>GoDS</res-ref-name>
       <jndi-name>java:/GoDS</jndi-name>
       </resource-ref>
       </entity>
       ...
       </enterprise-beans>
       </jboss>
      standardjbosscmp-jdbc.xml
      <jbosscmp-jdbc>
       <defaults>
       <datasource>java:/DefaultDS</datasource>
       <datasource-mapping>mySQL</datasource-mapping>
       ...
       </defaults>
       <type-mappings>
       <type-mapping>
       <name>mySQL</name>
       ...
       </type-mapping>
       </type-mappings>
       ...
      </jbosscmp-jdbc>
      Thanx, glb


        • 1. Re: Why Can't I Use Two MySQL Databases?
          darranl

          Your 'standardjbosscmp-jdbc.xml' says that all CMP beans should use 'java:/DefaultDS' unless overriden in the jbosscmp-jdbc.xml of the beans.

          Do you have a jbosscmp-jdbc.xml for the beans that is in your META-INF folder with the rest of the descriptors?

          • 2. Re: Why Can't I Use Two MySQL Databases?
            gberish

            Just in case anyone else refers to this topic, all it took was to repeate the section in the jbosscmp-jdbc.xml in my ejb.jar META-INF directory.

             <defaults>
             <datasource>java:/GoDS</datasource>
             <datasource-mapping>mySQL</datasource-mapping>
             ...
             </defaults>
            The <type-mappings> section did not have to be repeated.

            Thanx for all the help.