You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dennis Murphy <dm...@seas.upenn.edu> on 2001/06/28 06:06:57 UTC

Need Help understanding Oracle JDBCRealm

Hello,

BACKGROUND
I'm a new JSP developer who just moved a simple application over from JSERV
to mod_jk.

My small application worked fine under JSERV. All it needs to do is connect
to an Oracle database to verify a USERNAME & PASSWORD.

QUESTION
1. Do you have to establish a JDBCRealm in order to connect to a database?

BACKGROUND
In my server.xml file I commented out the SimpleRealm code and inserted the
following:
<!-- Added Oracle JDBC support dmurphy 25-Jun-01 -->
<RequestInterceptor
    className="org.apache.tomcat.request.JDBCRealm"
    debug="99"
    driverName="oracle.jdbc.driver.OracleDriver"
    connectionURL="jdbc:oracle:thin:@localhost:1521:testdb"
 />

I'm unable to start TOMCAT with this code in place.

QUESTION
1. I placed oracle.jdbc.driver.OracleDriver in my webapp WEB-INF/classes
folder.  Thus its accessible to my application.  Is this the correct place
to put the Oracle driver?  Do I need to add the Oracle driver to my
classpath?

BACKGROUND
Since I'm unable to get TOMCAT to start with my JDCBRealm in place - I
commented it out in my server.xml file along with the SimpleRealm.

QUESTION
Must I have at least the SimpleRealm in place?

BACKGROUND
I moved on and was able to create a CONNECTION POOL using a CONNECTION POOL
servlet that worked with my JSERV application.  The ConnectionPool servlet
uses package javaservlets.jdbc

Anyway, when my application attempts to create a result set (rs) it blows
up. As seen below in the code segment:

    Connection conn = connectionPool.getConnection();
    Statement qs = conn.createStatement();
    ResultSet rs =
      qs.executeQuery(SELECT_PASSWORD +
      QUOTE + user + QUOTE);

This code gives me the following errors (condensed for readability)
Internal Servlet Error:
javax.servlet.ServletException
 at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:459)
...
Root cause:
java.lang.NullPointerException
 at Chapter3.SessionManager.login(./Chapter3/SessionManager.java:373)
...

QUESTION
Can someone please help me understand how to connect to an Oracle database
using Tomcat?  Do I need to setup a JDCBRealm?

Thank you for your assistance,
Sincerely,
Dennis