3 Replies Latest reply on Apr 22, 2002 9:26 AM by davidjencks

    Alternate DataSource Usage (MySQL)

    tysonbrown

      I am currently running JBOSS 2.4 and am having a problem getting the CMP bean to talk to the MySQL DB. If I go into the jboss.jcml file, make the appropriate entries, comment out the DefaultDS and Hypersonic entries, then make my mysql datasource the default one, it will connect to the database and that table fine. If I leave the hypersonic one as default, or try to reference mySQL as anything other than the default datasource, then I can see my data getting pushed into the hypersonic tables.

      I get the distinct impression that I have the jboss.jcml configured properly, but perhaps my ejb-jar.xml file isn't right?? I am getting the message when JBoss starts up that it is loading the MySQLDS datasource properly. Any help or advice would be greatly appreciated.

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
      <ejb-jar>
      <enterprise-beans>

      <ejb-name>Tbltest</ejb-name>
      messagestore.TbltestHome
      messagestore.Tbltest
      <ejb-class>messagestore.TbltestBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>messagestore.TbltestPK</prim-key-class>
      False
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>message</field-name>
      </cmp-field>
      <primkey-field />
      <resource-ref>
      <res-ref-name>jdbc/MySQLDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>


      <ejb-name>Tbltest</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Never</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      (and the jcml....)

      MySQLDS
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
      jdbc:mysql://undertow/test
      sa
      sa
      0
      5





      -Thanks :)



        • 1. Re: Alternate DataSource Usage (MySQL)
          davidjencks

          The DataSource is set up properly. The problems are in getting your code to find it.

          You might be able to say

          <res-ref-name>java:/MySQLDS</res-ref-name>

          or you could add a link in jboss.xml connecting
          jdbc/MySQLDS (the name your code uses, as in
          java:/comp/env/jdbc/MySQLDS) to java:/MySQLDS (the jndi binding location)

          I think how to do this is covered in the online manual and is used in several testcases.

          • 2. Re: Alternate DataSource Usage (MySQL)
            chgrimm

            the use of DefaultDS as default datasource for CMP is specified in the
            standardjaws.xml file in your jboss config directory

            you can change either this ( which i would not recommend ) or
            put your own jaws.xml in the META-INF directory
            of your ejb jar

            in your case, the jaws.xml should have at least the following content:

            <?xml version="1.0" encoding="UTF-8"?>

            java:/MySQLDS

            • 3. Re: Alternate DataSource Usage (MySQL)
              davidjencks

              Thanks chgrimm, my reply is irrelevant, I was misled by the ejb-ref stuff and did not notice "CMP"