Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with oracle jdbc and jsp

1 view
Skip to first unread message

swetha

unread,
Jul 2, 2003, 4:56:22 AM7/2/03
to

Hi folks,

I have been trying to connect to jsp with oracle jdbc (oci8). I have
jdk1.3.1 and oracle 8i installed in my system. When I run the
following program

------------------------------------------------------------------------
--------------
<html>
<head>
<basefont face="Arial">
<%@ page language="java" import="java.sql.*" %>

<%!
//define variable
String empName;
%>

<table border="2" cellspacing="2" cellpadding="5">

<tr>
<td><b>Emp Name</b></td>
</tr>

<%

Connection connection = null;
Statement statement = null;
ResultSet results = null;

Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:oci8@";
connection = DriverManager.getConnection(url, "scott", "tiger");
statement = connection.createStatement();
String Query = "SELECT ENAME FROM EMP";
results = statement.executeQuery("select ENAME from EMP");
while(results.next())
{
empName = results.getString("ENAME");
out.println("<tr><td>" + empName + "</td>");
%>

<tr>

<%
}
//close connection
results.close();
statement.close();
connection.close();

%>

</table>
</body>
</html>
------------------------------------------------------------------------
---------------
I get the following error

------------------------------------------------------------------------
---------------
type Exception report

message Internal Server Error

description The server encountered an internal error (Internal Server
Error) that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: oracle.jdbc.driver.OracleDrivers
at org.apache.jasper.runtime.PageContextImpl.handlePageExceptio-
n(PageContextImpl.java:463)
at org.apache.jsp.success$jsp._jspService(success$jsp.java:217)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase-
.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.servi-
ce(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServl-
et.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet-
.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFi-
lter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(App-
licationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(Standar-
dWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(Standar-
dContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(A-
uthenticatorBase.java:475)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.valves.CertificatesValve.invoke(Certific-
atesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardCont-
ext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHo-
stValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(Error-
DispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorRepo-
rtValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogVa-
lve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(Standard-
EngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(Htt-
pProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpPro-
cessor.java:1107)
at java.lang.Thread.run(Thread.java:539)


root cause

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDrivers
at org.apache.catalina.loader.WebappClassLoader.loadClass(Webap-
pClassLoader.java:1394)
at org.apache.catalina.loader.WebappClassLoader.loadClass(Webap-
pClassLoader.java:1243)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoade-
r.java:198)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoade-
r.java:132)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:324)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:135)
at org.apache.jsp.success$jsp._jspService(success$jsp.java:88)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase-
.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.servi-
ce(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServl-
et.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet-
.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFi-
lter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(App-
licationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(Standar-
dWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(Standar-
dContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(A-
uthenticatorBase.java:475)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.valves.CertificatesValve.invoke(Certific-
atesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardCont-
ext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHo-
stValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(Error-
DispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorRepo-
rtValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogVa-
lve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(Standard-
EngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(Standar-
dPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPip-
eline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase-
.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(Htt-
pProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpPro-
cessor.java:1107)
at java.lang.Thread.run(Thread.java:539)

------------------------------------------------------------------------
---------------

--
Posted via http://dbforums.com

Andy Flowers

unread,
Jul 2, 2003, 5:40:27 AM7/2/03
to
Do you have the jdbc drivers in your classpath.

They will either have to be in the machines classpath before starting the
web server, or they will need to be in the WEB-INF/lib directory, with the
second option being the preferred method.

"swetha" <membe...@dbforums.com> wrote in message
news:3065681.1...@dbforums.com...

swetha

unread,
Jul 2, 2003, 7:54:21 AM7/2/03
to

I have added classes12.zip and nls_charset12.zip which I got with Oracle
8i installation to the class path. I copied them in C:\Program
Files\Apache Tomcat 4.0\webapps\examples\jsp\ora\WEB-INF\lib directory
and added them to the classpath and still it doen't work :(


Originally posted by Andy Flowers

> Do you have the jdbc drivers in your classpath.
>
> They will either have to be in the machines classpath before
> starting the
> web server, or they will need to be in the WEB-INF/lib directory,
> with the
> second option being the preferred method.

--
Posted via http://dbforums.com

Andy Flowers

unread,
Jul 2, 2003, 8:35:55 AM7/2/03
to
I believe they need to be .jar files to be picked up automatically. Either
copy the .jar versions or just rename the .zip files to be .jar.

"swetha" <membe...@dbforums.com> wrote in message

news:3066179.1...@dbforums.com...

swetha

unread,
Jul 2, 2003, 10:01:45 AM7/2/03
to

I have renamed the files to .jar and added them to the class path with
"set classpath" and then also did an autoexec at the command prompt.
Then I start tomcat 4.0 and then run the program, but still doesnt work
:( is there any way i can get more quick replies from u .. if u r
online or so ... my yahoo id is vasuki_t...@yahoo.com


Originally posted by Andy Flowers

> I believe they need to be .jar files to be picked up
> automatically. Either
> copy the .jar versions or just rename the .zip files to be .jar.
>

> "swetha" wrote in message
> news:3066179.1...@dbforums.com"]news:3066179.1057146861@d-
> bforums.com[/url]...


> > I have added classes12.zip and nls_charset12.zip which I got
> with Oracle
> > 8i installation to the class path. I copied them in
> C:\Program
> > Files\Apache Tomcat 4.0\webapps\examples\jsp\ora\WEB-INF\lib
> directory
> > and added them to the classpath and still it doen't work :(
> > Originally posted by Andy Flowers
> > > Do you have the jdbc drivers in your classpath.
> > >
> > > They will either have to be in the machines classpath
> before
> > > starting the
> > > web server, or they will need to be in the WEB-INF/lib
> directory,
> > > with the
> > > second option being the preferred method.
> > --
> Posted via

http://dbforums.com/http://dbforums.com

Paul Cooper

unread,
Jul 2, 2003, 10:56:08 AM7/2/03
to
On Wed, 02 Jul 2003 14:01:45 +0000, swetha <membe...@dbforums.com>
wrote:

>
>I have renamed the files to .jar and added them to the class path with
>"set classpath" and then also did an autoexec at the command prompt.
>Then I start tomcat 4.0 and then run the program, but still doesnt work
>:( is there any way i can get more quick replies from u .. if u r
>online or so ... my yahoo id is vasuki_t...@yahoo.com
>
>

"set CLASSPATH... " - it is case sensitive.

Blue Jean

unread,
Jul 2, 2003, 6:27:27 PM7/2/03
to
By default, Tomcat does not use the system classpath at all,
that is, it does not matter what classpath you set outside
the container. You can modify tomcat's setclasspath script,
or even better, put your jars in the corresponding WEB-INF/lib
folder.
_________________________________
Bugzero all-in-one: bug tracking & help desk
Free try: http://www.websina.com/bugzero/


Paul Cooper <paul....@Nobasspam.ac.uk> wrote in message news:<mis5gvsr17uh467ra...@4ax.com>...

swetha

unread,
Jul 3, 2003, 12:00:14 AM7/3/03
to

I have put the zip files (renamed to jar as suggested by a member in the
post) in WEB-INF/ilb folder. What does Tomcat classpath mean. Is it
different from the normal CLASSPATH we use in windows

Originally posted by Blue Jean

> By default, Tomcat does not use the system classpath at all,
> that is, it does not matter what classpath you set outside
> the container. You can modify tomcat's setclasspath script,
> or even better, put your jars in the corresponding WEB-INF/lib
> folder.
> _________________________________
> Bugzero all-in-one: bug tracking & help desk

> Free try: http://www.websina.com/bugzero/"]http://www.websina.-
> com/bugzero/[/url]
>
>
> Paul Cooper wrote in message news:news:...


> > On Wed, 02 Jul 2003 14:01:45 +0000, swetha

> > wrote:
> >
> > >
> > >I have renamed the files to .jar and added them to the class
> path with
> > >"set classpath" and then also did an autoexec at the command
> prompt.
> > >Then I start tomcat 4.0 and then run the program, but still
> doesnt work
> > >:( is there any way i can get more quick replies from u .. if
> u r
> > >online or so ... my yahoo id is
> vasuki_t...@yahoo.com
> > >
> > >
> >
> "set CLASSPATH... " - it is case sensitive.

--
Posted via http://dbforums.com

bung ho

unread,
Jul 3, 2003, 11:18:53 AM7/3/03
to
the Tomcat classpath still means "look in this path for classes" as
usual. it sets it up differently however, and Blue Jean is correct in
stating that the tomcat server will normally ignore whatever you set
the CLASSPATH environment variable to be--it uses several different
classloaders to facilitate separation between multiple webapps. see

http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html

for detailed information on how it does that.

now, as for your particular problem, renaming to jar and placing in
WEB-INF/lib should do it. however, i noticed that the
ClassNotFoundException refers to "oracle.jdbc.driver.OracleDrivers"
(note S at the end). how does this happen? there's no such class as
"..OracleDrivers" as far as i know.

other than that, it also looks like your jdbc url isn't quite
correct/complete, but that wouldn't have anything to do with your
classpath problem.

swetha <membe...@dbforums.com> wrote in message news:<3070014.1...@dbforums.com>...

Andy Flowers

unread,
Jul 3, 2003, 1:20:39 PM7/3/03
to
Doh!! Drivers vs Driver - entirely correct, should have noticed that
earlier, but wood, trees, not seeing springs to mind.

The JSP code states Class.forName("oracle.jdbc.driver.OracleDriver");
whereas the Exception states javax.servlet.ServletException:
oracle.jdbc.driver.OracleDrivers

Is there some mismatch here ?, is the code posted EXACTLY the same as that
which generated the error ?

"bung ho" <bun...@hotmail.com> wrote in message
news:567a1b1.03070...@posting.google.com...

swetha

unread,
Jul 4, 2003, 2:51:13 AM7/4/03
to

I copy pasted the exact code. Now when I do the same again I don't get
that extra s. Still the programs aren't running though. I have put the
jar files in lib and also WEB-INF/lib directory!

Originally posted by Andy Flowers

> Doh!! Drivers vs Driver - entirely correct, should have noticed that
> earlier, but wood, trees, not seeing springs to mind.
>
> The JSP code states Class.forName("oracle.jdbc.driver.OracleDriver");
> whereas the Exception states javax.servlet.ServletException:
> oracle.jdbc.driver.OracleDrivers
>
> Is there some mismatch here ?, is the code posted EXACTLY the
> same as that
> which generated the error ?
>

> "bung ho" wrote in message
> news:567a1b1.03070...@posting.google.com"]news:567a1-
> b1.03070307...@posting.google.com[/url]...


> > the Tomcat classpath still means "look in this path for classes"
> as
> > usual. it sets it up differently however, and Blue Jean is
> correct in
> > stating that the tomcat server will normally ignore whatever you
> set
> > the CLASSPATH environment variable to be--it uses several
> different
> > classloaders to facilitate separation between multiple webapps.
> see

> > http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loa-
> der-howto.html"]http://jakarta.apache.org/tomcat/tomcat-4.0-doc/c-
> lass-loader-howto.html[/url]


> > for detailed information on how it does that.
> > now, as for your particular problem, renaming to jar and placing
> in
> > WEB-INF/lib should do it. however, i noticed that the
> > ClassNotFoundException refers to
> "oracle.jdbc.driver.OracleDrivers"
> > (note S at the end). how does this happen? there's no such
> class as
> > "..OracleDrivers" as far as i know.
> > other than that, it also looks like your jdbc url isn't
> quite
> > correct/complete, but that wouldn't have anything to do with
> your
> > classpath problem.

> > swetha wrote in message
> news:news:...


> > > I have put the zip files (renamed to jar as suggested by a
> member in the
> > > post) in WEB-INF/ilb folder. What does Tomcat classpath mean.
> Is it
> > > different from the normal CLASSPATH we use in windows
> > >
> > >
> > >
> > > Originally posted by Blue Jean
> > > > By default, Tomcat does not use the system classpath at
> all,
> > > > that is, it does not matter what classpath you set
> outside
> > > > the container. You can modify tomcat's setclasspath
> script,
> > > > or even better, put your jars in the corresponding
> WEB-INF/lib
> > > > folder.
> > > > _________________________________
> > > > Bugzero all-in-one: bug tracking & help desk

> > > > Free try: http://www.websina.com/bugzero/"]http://ww-
> w.websina.com/bugzero/[/url]"]http://www.websina.-/"]http:/-
> /www.websina.-[/url]


> > > > com/bugzero/[/url]
> > > >
> > > >
> > > > Paul Cooper wrote in message

> news:news:news:news:...


> > > > > On Wed, 02 Jul 2003 14:01:45 +0000, swetha
> > > > > wrote:
> > > > >
> > > > > >
> > > > > >I have renamed the files to .jar and added them to the
> class
> > > path with
> > > > > >"set classpath" and then also did an autoexec at the
> command
> > > prompt.
> > > > > >Then I start tomcat 4.0 and then run the program, but
> still
> > > doesnt work
> > > > > >:( is there any way i can get more quick replies from u
> .. if
> > > u r
> > > > > >online or so ... my yahoo id is
> > > vasuki_t...@yahoo.com
> > > > > >
> > > > > >
> > > > >
> > > "set CLASSPATH... " - it is case sensitive.

Andy Flowers

unread,
Jul 4, 2003, 12:44:09 PM7/4/03
to
Is the error message still the same ? If not the what is it now ?

Which WEB-INF/lib ? The one that relates to the web site I hope ?


Richard Hurt

unread,
Jul 5, 2003, 7:48:24 AM7/5/03
to
Hey guys,

Sorry to jump in the middle here but I am having pretty much the same
problem with trying to get DB2 drivers working under Tomcat 4.1 on AIX
5.1L. Grrr...I have placed db2java.zip EVERYWHERE I can think of
(common/lib, shared/lib, WEB-INF/lib, etc.) I even renamed it to .jar
with no effect on the error.

I made up a simple JSP (that works great under WebSphere on the same
machine) to test my DB2 connection. When I call it from my browser,
here is the message I get:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] /opt/tomcat-4.1.24/work/Standalone/localhost/stcepmweb/testDB2_jsp.java:8:
package COM.ibm.db2 does not exist
[javac] import COM.ibm.db2.*;
[javac] ^
[javac] 1 error

Is this something like the error you are seeing?

Later...
Richard


"Andy Flowers" <andrew....@npspam.ntlworld.com> wrote in message news:<vaiNa.3494$nP....@newsfep4-winn.server.ntli.net>...

Andy Flowers

unread,
Jul 5, 2003, 7:56:36 AM7/5/03
to
If the COM meant to be in upper case ? Generally package names are in lower
case.

"Richard Hurt" <rh...@thepoint.net> wrote in message
news:1a2a654d.03070...@posting.google.com...

0 new messages