tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlton Lo" <>
Subject tomcat JNDI DB connection pool to Oracle
Date Wed, 19 Jun 2002 15:10:28 GMT
I've been successfully making JDBC connections directly in my JSP 

ora_conn = DriverManager.getConnection("jdbc:oracle:oci8:@oracle8", "user", "password");

Not I try to setup my Tomcat 4.0.2's JNDI DB connection pool, but I can't get it to work

Here is what I've done so far

1. Move the Oracle Drivers ( into <TOMCAT_HOME>\lib and 

<TOMCAT_HOME>\common\lib directories and rename them to classes12.jar

2. Added the following codes to my webapp's web.xml


3. Added the following codes within the <Context> </Context> tag of <TOMCAT_HOME>\conf\server.xml

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

4. try to make connection within my JSP

<%@ page import="*" %>
<%@ page import="*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.naming.*" %>

try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/ora");
Connection conn1 = ds.getConnection();
out.println("Win2000 Oracle Connected!<br>");
catch (SQLException E) {
out.println("<br>unable to get connection on ora !"); 
out.println("<br>SQLException: " + E.getMessage());
out.println("<br>SQLState: " + E.getSQLState());
out.println("<br>VendorError: " + E.getErrorCode());

Results :
unable to get connection on ora ! 
SQLException: Cannot load JDBC driver class 'null' 
SQLState: null 
VendorError: 0 

Why? I'm able to make connection call JDBC directly in my other JSP, but not when I try to
get the connection via JNDI Context ...??

Thank you in advnace

Carlton Lo
150 Speen Street
Framingham, MA 01701
Tel: 508-663-1089

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

View raw message