You have to configure the resource reference before you can use it.

Put this into your ejb-jar.xml

        <resource-ref>
          <res-ref-name>jdbc/mySQLDB</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
        </resource-ref>


Put this into your jboss.xml

      <resource-ref>
        <res-ref-name>jdbc/mySQLDB</res-ref-name>
        <resource-name>java:/mySQLDB</resource-name>
      </resource-ref>

Nguyen Thanh Phong                           Tel: 84-8-837 25 06/837 25 07
Saigon Software Development Company (SDC)    Fax: 84-8-837 25 11
10 Co Giang Street, Dist I, HCMC             Email:
[EMAIL PROTECTED]
Vietnam

----- Original Message -----
From: Jeff Holmes <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 26, 2001 8:07 AM
Subject: [JBoss-user] Getting BMP JDBC Connection - HELP...


> I'm using the Enterprise Java Beans book from Oreilly to learn how to use
> EJB's.  I am stuck right now.  I use mySQL and have succeded in creating a
> CMP, but I anc not get a DB connection using the BMP.
>
> I have added this in the jboss.jcml:
>   <mbean code="org.jboss.jdbc.XADataSourceLoader"
> name="DefaultDomain:service=XADataSource,name=mySQLDB">
>     <attribute name="PoolName">mySQLDS</attribute>
>     <attribute
>
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImp
> l</attribute>
>     <attribute
name="URL">jdbc:mysql://localhost:3306/testClass</attribute>
>     <attribute name="JDBCUser">test</attribute>
>     <attribute name="Password">test</attribute>
>   </mbean>
>
> And this works great with CMP.
>
> Here is the method that is in the Bean:
>
> private Connection getConnection() throws SQLException {
>   try {
>     Context jndiCntx = new InitialContext();
>     DataSource ds =
> (DataSource)jndiCntx.lookup("java:/comp/env/jdbc/mySQLDB");
>     return ds.getConnection();
>   } catch (Exception e) {
>     throw new EJBExcpetion(e);
>   }
> }
>
> I have the JAWS file listed later in this, but where does the
lookup(String)
> name really come from?  Is is from the Jaws file?  The datasource
'mySQLDS'?
> I'am lost.  The code always fails on the jndiCntx.lookup(String) and I
can't
> seem to get past this.  Help would be greatly appreciated, GREATLY!!
> Thanks, Jeff Holmes
>
> Here is what is in the JAWS.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <jaws>
>   <datasource>mySQLDS</datasource>
>   <type-mapping>mySQL</type-mapping>
>   <enterprise-beans>
>     <entity>
>       <ejb-name>user</ejb-name>
>       <table-name>user</table-name>
>       <create-table>false</create-table>
>       <remove-table>false</remove-table>
>       <prim-key-class>int</prim-key-class>
>       <cmp-field>
>         <field-name>id</field-name>
>         <column-name>employee_number</column-name>
>       </cmp-field>
>       <cmp-field>
>         <field-name>lastName</field-name>
>         <column-name>last_name</column-name>
>       </cmp-field>
>       <cmp-field>
>         <field-name>firstName</field-name>
>         <column-name>first_name</column-name>
>       </cmp-field>
>       <cmp-field>
>         <field-name>middleInit</field-name>
>         <column-name>middle_init</column-name>
>       </cmp-field>
>     </entity>
>   </enterprise-beans>
> </jaws>
>
>
>
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to