Hi,
To get DataSource object of a connection pool which I cerated in weblogic 7.0, I can do JNDI loop in two ways...
1.DataSource ds = (DataSource) ic.lookup("sampleConnPool");
where "sampleConnPool" is the JNDI name of the pool which i created....
2. private String dbName = "java:comp/env/jdbc/sampleConnPool";
where "java:comp/env/jdbc/sampleConnPool" is having entry in ejb-jar.xml
<resource-ref>
<res-ref-name>jdbc/sampleConnPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
DataSource ds = (DataSource) ic.lookup(dbName);
can somebody tell me what is the difference between two ways of doing JNDI lookup...
--Suresh
-
JNDI look up...... (4 messages)
- Posted by: suresh muraki
- Posted on: April 19 2003 12:24 EDT
Threaded Messages (4)
- JNDI look up...... by make ship go on April 21 2003 16:02 EDT
- JNDI look up...... by suresh muraki on April 22 2003 09:02 EDT
-
also look at weblogic-ejb-jar.xml by Gwyn Evans on April 22 2003 11:28 EDT
- jndi.properties file by atul phulambrikar on February 09 2005 08:56 EST
-
also look at weblogic-ejb-jar.xml by Gwyn Evans on April 22 2003 11:28 EDT
- JNDI look up...... by suresh muraki on April 22 2003 09:02 EDT
-
JNDI look up......[ Go to top ]
- Posted by: make ship go
- Posted on: April 21 2003 16:02 EDT
- in response to suresh muraki
Although both approaches are valid there are some slight differences. The first approach looks up the datasource directly in the jndi tree while the second approach goes through the ejb enc to look up the datasource. When resource references are declared in ejb, those references are local only to the bean they are declared in. So the reference declared in the second approach is only visible to the ejb declaration that contains it. This provides a layer of indirection which may be useful for resolving conflicts. -
JNDI look up......[ Go to top ]
- Posted by: suresh muraki
- Posted on: April 22 2003 09:02 EDT
- in response to make ship go
Hi,
Thanxs, Can, u explain the statement in detail "This provides a layer of indirection which may be useful for resolving conflicts"....
--Thanks\suresh -
also look at weblogic-ejb-jar.xml[ Go to top ]
- Posted by: Gwyn Evans
- Posted on: April 22 2003 11:28 EDT
- in response to suresh muraki
There's a 2nd xml file that's appserver specific and while by default you'll have the same names there, it allows you the option of having a generic name in the code java:comp/env/jdbc/MyDataSource but at deploy time, specify exactly which 'real' datasource that it linked to.
How much this is of use comes down to how generic/re-usable your bean/environment needs to be... -
jndi.properties file[ Go to top ]
- Posted by: atul phulambrikar
- Posted on: February 09 2005 08:56 EST
- in response to Gwyn Evans
interesting to know the diff. in the two approaches...
we can use jndi.properties file to describe:
// WEB-INF/classes/jndi.properties
java.naming.factory.initial=WLInitialContextFactory
java.naming.provider.url=t3://localhost:port/<application>
//java.naming.security.principal=<username>
//java.naming.security.credentials=<password>
to make the code generic..