tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fawaz Ahmad <>
Subject JNDI help
Date Fri, 04 Oct 2002 21:17:38 GMT

Can anyone help me with this problem.  I have read up on Tomcat JNDI from
the Tomcat HowTo webpage and tried to implement it in my
servlet.  Unfortunately, I can not seem to get it to work.  My servlet
works fine when i use the original code to access the database:

      //establish the connection
      Connection conn = DriverManager.getConnection(url,dbUsr, dbPsw);

But when I try using the JNDI service my servlet doesn't seem to access
the database.  I am using the following code.  Is ther something trival
that I might be leaving out?

  Context ctx = (Context) new InitialContext().lookup("java:comp/env");
  Connection conn = ((DataSource) ctx.lookup("jdbc/WebOE")).getConnection();

where my servlet's web.xml is:



And my entry to server.xml is:

<Context path="/WebOE" docBase="WebOE" debug="0" reloadable="true"/>

<Resource name="jdbc/WebOE" auth="Container" type="javax.sql.DataSource"/>
  <ResourceParams name="jdbc/WebOE">


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message