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