2 Replies Latest reply on Oct 30, 2002 9:10 PM by Joel Vogt

    CMP how do I indicate which database to use

    mBird Newbie

      I can't see how this could work -- could someone please explain:

      I deploy my ejb. None of the files (see below) tell the ejb what database to use (non of them have a jndi name indicating the db) yet it works.

      So the question is, given the below, how does the ejb know what database conenction to use if you do not specify it in any of your deployed xml files?

      1.) I have MySQL connected to JBoss (...-service.xml and ...-jdbc.xml file) -- works fine
      2.) I create simple Entity bean (Test.java, TestBean.java, TestHome.java)
      3.) I create ejb-jar.xml
      4.) That's it -- no other files -- I package up into a jar and deploy to JBoss (just copy it to the deploy dir)
      5.) I make a simple java client

      The deploy works and the client works -- yet I never told JBoss what db to use???

      The deployable jar is at http://www.mattkelli.com/download/MySQLds1.jar -- if you unjar it you will see only my four files.

      Note the ejb-jar.xml file does not indicate a database
      as you see below

      <?xml version = '1.0' encoding = 'windows-1252'?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>

      Entity Bean ( CMP )
      <display-name>Book</display-name>
      <ejb-name>Book</ejb-name>
      mypackage3.BookHome
      mypackage3.Book
      <ejb-class>mypackage3.impl.BookBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Book</abstract-schema-name>
      <cmp-field>
      <field-name>title</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>author</field-name>
      </cmp-field>
      <primkey-field>title</primkey-field>

      </enterprise-beans>
      </ejb-jar>