This content has been marked as final.
Show 1 reply
-
1. Re: JBoss3.0 -> CMP and datasource
aloubyansky Oct 7, 2002 2:14 PM (in response to mik1)To lookup a datasource in java:/comp/env, it should be bound there first. This is done the following way.
in ejb-jar.xml:
<ejb-name>MyEJB</ejb-name>
...
<resource-ref>
<!-- this is a logical name -->
<res-ref-name>jndi/ApplicationDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
in jboss.xml:
<ejb-name>MyEJB</ejb-name>
...
<resource-ref>
<res-ref-name>jndi/ApplicationDS</res-ref-name>
<!-- this is actual JNDI name -->
<jndi-name>java:/KNInnerDS</jndi-name>
</resource-ref>
Then in some MyEJB's method:
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup( "java:/comp/env/jndi/ApplicationDS" );
But if SELECT, UPDATE and DELETE are done this way, then why use CMP?