472,353 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

HTTP Status-500 error while connecting to DB2 using tomcat 4.1.34

iam a starter to db2 & jdbc.i have a servlet program which connects to ibm db2
using jdbc.when i run this using apache tomcat 4.1.34 , it is showing a
error message of HTTP STATUS 500

my jdbc program is as follows

import java.sql.*;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import COM.ibm.db2.jcc.*;
import COM.ibm.db2.jdbc.app.*;
import COM.ibm.db2.jdbc.net.*;
public class tgsample {
//Loads Type 2 Driver

//For type 4 Driver: Class.forName("com.ibm.db2.jcc.DB2Driver");
catch (ClassNotFoundException e)
System.err.println("Could not load DB2 driver \n");

public static void main(String args[])

String url = "jdbc:db2://localhost:50000/MYLSTDB";
String uname ="db2admin", psswrd ="varma";


//Connect to a database
Connection conn = DriverManager.getConnection(url, uname, psswrd);

//Create statement for the connections
Statement stmt = conn.createStatement();

//Execute the query
ResultSet rs = stmt.executeQuery(query);

//Loop through the result and print it out
System.out.println("\nNAME \tROLLNO \tGPA \tCLASS");

while (rs.next())
System.out.print(rs.getString(1) + " \t" );
System.out.print(rs.getString(2)+" \t");
System.out.print(rs.getString(3)+" \t");
System.out.println(rs.getString(4)+" \t");


catch (SQLException e)
System.out.println("SQL Exception: ");

} //class

* This class prompts the user for a password and attempts to mask input with ""

class PasswordField {

*@param prompt The prompt to display to the user.
*@return The password as entered by the user.

String getPassword(String prompt) throws IOException {
// password holder
String password = "";
int counter = 0;
MaskingThread maskingthread = new MaskingThread(prompt);
Thread thread = new Thread(maskingthread);
// block until enter is pressed
while (true) {
char c = (char)System.in.read();
// assume enter pressed, stop masking

if (c == '\r') {
c = (char)System.in.read();
if (c == '\n') {
} else {
} else if (c == '\n') {
} else {
// store the password
password += c;
return password;

* This class attempts to erase characters echoed to the console. It's made to
* work with PasswordField class (see above).

class MaskingThread extends Thread {
private boolean stop = false;
private int index;
private String prompt;

*@param prompt The prompt displayed to the user
public MaskingThread(String prompt) {
this.prompt = prompt;

* Begin masking until asked to stop.
public void run() {
while(!stop) {
try {
// attempt masking at this rate
}catch (InterruptedException iex) {
if (!stop) {
System.out.print("\r" + prompt + " \r" + prompt );

* Instruct the thread to stop masking.
public void stopMasking() {
this.stop = true;

also iam able to connect to database when i run it normally.
the problem is when i run it using a servlet.

what all changes i have to make to tomcat?please explain clearly.
also explain clearly about how to set the classpath clearly?

the error list i get is

HTTP Status 500 -


type Exception report


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


java.lang.ClassCastException: tgsample
at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:847)
at org.apache.catalina.core.StandardWrapper.allocate( StandardWrapper.java:612)
at org.apache.catalina.servlets.InvokerServlet.serveR equest(InvokerServlet.java:367)
at org.apache.catalina.servlets.InvokerServlet.doGet( InvokerServlet.java:131)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:809)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:198)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:144)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:595)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:432)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:954)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:138)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:595)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:432)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:954)
at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2459)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:132)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:595)
at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:593)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:593)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:432)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:954)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:126)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:595)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:432)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:954)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


Apache Tomcat/4.1.34
Dec 24 '06 #1
1 4267
1,754 Expert 1GB
Hi there,

Status code 500 refer to server misconfiguration / access level related problems. Check these details out, hope it helps. Good luck & Take care.
Dec 24 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Mike C | last post by:
First of all, I am a complete newbie to Python, but have been impressed with how easy the language has been to pick up. I am trying to write a...
by: OvErboRed | last post by:
Hi, I'm trying to determine whether a given URL exists. I'm new to Python but I think that urllib is the tool for the job. However, if I give it a...
by: Chris Fink | last post by:
How do I retrieve the HTTP Status code (ie 202, 404, etc) below? I am currently receiving the response text but unable to access the response...
by: Dhwanil Shah | last post by:
Hi, We have an aspx page designed in VS.NET 2003. Our requirement is that a client (another application), sends HEAD requests to our application...
by: inferno2000 | last post by:
Let's say if I want to send a http "Post" request to a url, and check the http status code later. How should I write the code? I have found example...
by: Frances | last post by:
Firefox is not respecting window.status, examples in this pg http://www.csua.berkeley.edu/~jgwang/jsform02.htm are ignored by Firefox.. why is...
by: xcampanoli | last post by:
When I uncomment either of the http urls below instead of the local file, I always get a readyStatus of zero, and I never get past trace 2 alert. ...
by: rpjd | last post by:
I am having a problem getting the http.status of an xmlhttprequest. The request readystate has come back as readystate 4, but then it stops without...
by: unclesteve | last post by:
I am working on a project for a law firm where the different files are either boxed or unboxed. Unboxed files can be on a lawyer's desk, on the...
by: tvnaidu | last post by:
I wrote a status page HTML code, here I have 8 port status, it prints first 7 and last status it won't print, from there onwards it won't print...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.