File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes BEA/Weblogic and the fly likes Oracle JDBC connection using JNDI lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Oracle JDBC connection using JNDI lookup" Watch "Oracle JDBC connection using JNDI lookup" New topic

Oracle JDBC connection using JNDI lookup

Lars Ulrich

Joined: Dec 03, 2002
Posts: 3
I want to connect to an Oracle database using a servlet. I have set up the Connection Pool and Data Source in Weblogic. How do I write code for a JNDI lookup to access the Connection Pool and Data Source that I set up?
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
See the BEA documentation here: Using DataSources.
meital ben

Joined: Jun 05, 2002
Posts: 12
If you are using a DataSource :
// Obtain a Datasource connection from the WebLogic JNDI tree.
Context ctx = null;

// Put connection properties in to a hashtable.
Hashtable ht = new Hashtable();
// Get a context for the JNDI look up
ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("put here your DataSource JNDI Name");
conn = ds.getConnection();
[ December 03, 2002: Message edited by: meital ben ]

Simon Kelly

Joined: Oct 02, 2002
Posts: 11
How do you bind the database connection to the JNDI Lookup. What xml dd files are you required to edit and what entries do you make? Is there any documentation provided by WL for these questions - apart from instructions on how to use their Management Console?
Thanks in advance...
I agree. Here's the link:
subject: Oracle JDBC connection using JNDI lookup
It's not a secret anymore!