[jboss-user] [EJB 3.0] - Re: Why is my jdbc/database not in the local ENC?
waynebaylor
do-not-reply at jboss.com
Wed Sep 5 14:05:45 EDT 2007
Use the ejb-jar.xml to specify what is in your ENC and jboss.xml to map it to the JNDI name.
For example, to have access to the default datasource, java:/DefaultDS, you would use the following:
| <ejb-jar ...>
| <enterprise-beans>
| <session>
| <ejb-name>MySessionBean</ejb-name>
| <local>my.local.MySessionLocal</local>
| <ejb-class>my.bean.MySessionBean</ejb-class>
|
| <resource-ref>
| <res-ref-name>jdbc/MyDataSource</res-ref-name>
| <res-type>javax.sql.DataSource</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
| </session>
| </enterprise-beans>
| </ejb-jar>
|
and
| <jboss ...>
| <enterprise-beans>
| <session>
| <ejb-name>MySessionBean</ejb-name>
| <resource-ref>
| <res-ref-name>jdbc/MyDataSource</res-ref-name>
| <resource-name>DefaultDS</resource-name>
| </resource-ref>
| </session>
| </enterprise-beans>
| </jboss>
|
and perform the lookup within MySessionBean as:
DataSource ds = (DataSource)new InitialContext().lookup("java:comp/env/jdbc/MyDataSource");
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081454#4081454
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081454
More information about the jboss-user
mailing list