Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JNDI with Datasources and multiple applications

Status
Not open for further replies.

UweBritfeld

Programmer
Apr 4, 2003
1
US
This may sound remedial but I'm running into a problem.

I've got a Websphere 4.0 server with both an IT and a DEV environment on it. I've created two Applications, one for DEV and one for IT.

I have a datasource for each: jndi/DBDev and jndi/DBIT.

As I move my code from Dev to IT, when I look up the datasource via JNDI, I don't want to have to change my ctx.lookup() when I change environments.

i.e.
ds = (DataSource)ctx.lookup("jdbc/DBDev"); in dev and
ds = (DataSource)ctx.lookup("jdbc/DBIT"); in IT.

My understanding is that I can accomplish this by creating entries in web.xml and ibm-web-bnd.xmi but it isn't working for me.

Here's what I have in web.xml:
<resource-ref id=&quot;ResourceRef_1&quot;>
<res-ref-name>DB/Chrome</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

In ibm-web-bnd.xmi in DEV I Have:
<resRefBindings xmi:id=&quot;ResourceRefBinding_1&quot; jndiName=&quot;jdbc/DBDev&quot;>
<bindingResourceRef href=&quot;WEB-INF/web.xml#ResourceRef_1&quot;/>
</resRefBindings>

And in ibm-web-bnd.xmi in IT I Have:
<resRefBindings xmi:id=&quot;ResourceRefBinding_1&quot; jndiName=&quot;jdbc/DBIT&quot;>
<bindingResourceRef href=&quot;WEB-INF/web.xml#ResourceRef_1&quot;/>
</resRefBindings>

I thought I could then do a lookup in JNDI for &quot;DB/Chrome&quot; in either environment and wind up pointing at the proper Datasource.

My problem is that JNDI can't find &quot;DB/Chrome&quot; at all. If I do the lookup on &quot;jdbc/DBIT&quot; or &quot;jdbc/DBDev&quot; it works fine.

My only other option is to specify the datasource name using a parameter.

Has anyone tried this, or am I way out in left field?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top