?
Solved

jsp internal server error

Posted on 2003-03-28
9
Medium Priority
?
338 Views
Last Modified: 2010-04-01
I got the following error while trying to connect to db2 database

Following is my code..................

<%@ page language="java" import="java.sql.*" %>

<%

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:db2:paolx","db2admin","nic20pao03lx#");
if (con==null)
  out.println("Couldn't established Connection");
Statement st=con.createStatement();

ResultSet m_rs;
String query2="select * from tb_operator";

m_rs=st.executeQuery(query2);
if(m_rs!=null)
  out.println("U R Authorised User");

%>


............................................................
Error Shown :->

type Exception report

message

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

exception

org.apache.jasper.JasperException: COM.ibm.db2.jdbc.app.DB2Driver
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
      at java.lang.Thread.run(Thread.java:536)


root cause

javax.servlet.ServletException: COM.ibm.db2.jdbc.app.DB2Driver
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
      at org.apache.jsp.jdbcjsp_jsp._jspService(jdbcjsp_jsp.java:63)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
      at java.lang.Thread.run(Thread.java:536)



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

0
Comment
Question by:vijyog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 1

Expert Comment

by:victorli
ID: 8230286
Try replace the first line of your code with the following:

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

0
 
LVL 3

Expert Comment

by:allahabad
ID: 8230560
replace:
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
with :
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");

0
 
LVL 19

Accepted Solution

by:
cheekycj earned 152 total points
ID: 8231561
your code seems fine.

leaving language="java" should be fine and removing newInstance() shouldn't be the issue.

try this code ( a little bit of refactoring done for you)

<%@ page language="java" import="java.sql.*" %>

<%

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:db2:paolx","db2admin","nic20pao03lx#");
if (con==null)
 out.println("Couldn't established Connection");
else {
  Statement st=con.createStatement();

  ResultSet m_rs;
  String query2="select * from tb_operator";

  m_rs=st.executeQuery(query2);
  if(m_rs!=null)
    out.println("U R Authorised User");
  else
    out.println("resultset was null");
  rs.close();
  st.close();
  con.close();
}
%>

Do you have the jdbc driver added to your classpath?

CJ
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 148 total points
ID: 8232857
>> Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
class name is case sensitive:
Class.forName("com.ibm.db2.jdbc.app.DB2Driver");
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8232871
kennethxu: I believe it is supposed to be COM.ibm.db2.jdbc.app.DB2Driver  if you look here you can see that IBM uses that too:
http://www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v8infocenter.d2w/report?target=mainFrame&fn=jdbcs-util-java.htm

you can look at other samples too on IBM's site.

CJ
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8233869
Oh, my mistake. Then it's the driver is not in classpath. the exception indicates the problem of finding the driver class.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8233909
Yeah, thats what I suspected too.

CJ
0
 
LVL 35

Expert Comment

by:girionis
ID: 10060950
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between cheekycj and kennethxu

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
Introducing Priority Question, our latest feature.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question