473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 {
static
{
try
{
//Loads Type 2 Driver
Class.forName("com.ibm.db2.jcc.DB2Driver");

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


public static void main(String args[])
{


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


String query = "SELECT * FROM VARMA.STUDENT";


try
{
//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(query);
System.out.println("\nNAME \tROLLNO \tGPA \tCLASS");
System.out.println("----------------------------");

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");
}

rs.close();
stmt.close();
conn.close();
}

catch (SQLException e)
{
System.out.println("SQL Exception: ");
System.err.println(e.getMessage());
}

}//main
} //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);
thread.start();
// block until enter is pressed
while (true) {
char c = (char)System.in.read();
// assume enter pressed, stop masking
System.out.flush();
maskingthread.stopMasking();

if (c == '\r') {
c = (char)System.in.read();
if (c == '\n') {
break;
} else {
continue;
}
} else if (c == '\n') {
break;
} 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
this.sleep(1);
}catch (InterruptedException iex) {
iex.printStackTrace();
}
if (!stop) {
System.out.print("\r" + prompt + " \r" + prompt );
}
System.out.flush();
}
}

/**
* 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

message

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

exception

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 4346
sashi
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

1
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 script that checks to see if the web / application...
2
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 non-existent file, it simply returns the 404 page....
4
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 status code. string strNewValue; string...
1
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 with Basic Auth header. Based on security criteria,...
2
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 to use WinHttp to send "Get" request and check...
19
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 this.. is there a solution.. thank you.. Frances
3
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. When I use the local file I get readyStatus 1 and...
1
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 confirming the http.status. Any help appreciated....
3
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 secretary's desk, or on a shelf in the back room. A...
0
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 footer also, if I make 10 instead 8, then it prints...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.