-
1. Re: overriding default JNDI context for a datasource
milowe Sep 26, 2003 5:25 AM (in response to malyg)Use reference to look up DataSource and you dont need to care about deploy JNDI name.
J2EE
<!-- JDBC DataSources (java:comp/env/jdbc) -->
<resource-ref>
My Data Source
<res-ref-name>jdbc/MyDatasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
WEBLOGIC
<resource-description>
<res-ref-name>jdbc/MyDatasource</res-ref-name>
<jndi-name>yourDeployName</jndi-name>
</resource-description>
JBOSS
<resource-ref>
<res-ref-name>jdbc/MyDatasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>yourDeployName</jndi-name>
</resource-ref>
Source (works on WL and JBOSS) :
Context ctx = new InitialContext();
DataSource ds = (DataSource)initial.lookup("java:comp/env/jdbc/MyDatasource");
/micke -
2. Re: overriding default JNDI context for a datasource
malyg Sep 30, 2003 12:00 PM (in response to malyg)Thanks micke, that works!
Also it seems that JBoss deploys the same datasource
under "java:comp/evn/jdbc/MyDatasource", which works in my case since Weblogic also deployed the datasouce under that name.
So, from what I've seen one can say that:
If you deploy a datasource with a name "jdbc/MyDatasouce" it can be located under the following names.
In Jboss - under "java:/jdbc/MyDatasouce" or under "java:comp/env/jdbc/MyDatasource"
In Weblogic - under "jdbc/MyDatasource" and "java:comp/env/jdbc/MyDatasouce"
Note: "java:comp/env" is the J2EE "recomended" component evrionement context, as far as I understand.
-alex -
3. Re: overriding default JNDI context for a datasource
malyg Oct 1, 2003 4:56 PM (in response to malyg)Never mind the last post. JBoss did not deploy my datasource under "java:comp/env".
micke's solution seems to be the only one that works
in my case.
My appologies.
-alex