tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlton Lo" <...@plurisinc.com>
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 

Class.forName("oracle.jdbc.driver.OracleDriver");
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 (classes12.zip) 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

<resource-ref>
<res-ref-name>jdbc/ora</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


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">
<parameter>
<name>user</name>
<value>system</value>
</parameter>
<parameter>
<name>password</name>
<value>manager</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:oracle:oci8:@oracle8</value>
</parameter>
</ResourceParams> 

4. try to make connection within my JSP

<%@ page import="java.net.*" %>
<%@ page import="java.io.*" %>
<%@ 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
ku 


Carlton Lo
Pluris
150 Speen Street
Framingham, MA 01701
Tel: 508-663-1089
mailto:clo@plurisinc.com



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message