• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle JDBC connection using JNDI lookup

 
Lars Ulrich
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the BEA documentation here: Using DataSources.
 
meital ben
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
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();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
// 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
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic