473,396 Members | 2,052 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,396 software developers and data experts.

Connecting servlet program with db2 gives an error

java-class not found driver nt found...COM.ibm.db2.jdbc.app.db2driver...

program is:

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import java.sql.*;
  3. import javax.servlet.*;
  4. import javax.servlet.http.*;
  5.  
  6. public class EmployeeDetails extends HttpServlet
  7. {
  8.     static int i;
  9.     Connection con;
  10.     PrintWriter out;
  11.     ResultSet rs;
  12.     public void init()
  13.     {
  14.         i=0;
  15.         con=null;
  16.         out=null;
  17.         rs=null;
  18.     }
  19.     public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
  20.  
  21.     {
  22.         i++;
  23.         out=res.getWriter();
  24.         out.println("<B>You are the"+i+"visitor to visit this site.</B><BR><BR>");
  25.  
  26.     try
  27.     {
  28.         Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
  29.                 con=DriverManager.getConnection("jdbc:db2:DB");
  30.         PreparedStatement pstmt=null;
  31.         String query=null;
  32.         query= "Select emp_fname, address, age, desig from system.Employee_Master where id=?";
  33.         pstmt=con.prepareStatement(query);
  34.         pstmt.setInt(1,Integer.parseInt(req.getParameter("id")));
  35.         rs=pstmt.executeQuery();
  36.         out.println("<B><center>Employee Details </center></B><BR><BR>");
  37.         ResultSetMetaData rsmd= rs.getMetaData();
  38.         int colcount=rsmd.getColumnCount();        
  39.                 out.println("<TABLE ALIGN = CENTER BORDER=1 CELLPADDING=2>");
  40.         out.println("<TR>");
  41.         for(int i=1; i<=colcount; i++)
  42.         {
  43.             out.println("<TH>" + rsmd.getColumnLabel(i)+"</TH>");
  44.         }
  45.         out.println("</TR>");
  46.         while(rs.next())
  47.         {
  48.             out.println("<TR>");
  49.             out.println("<TD>" + rs.getString("emp_fname") + "</TD>");
  50.             out.println("<TD>" + rs.getString("address") + "</TD>");        
  51.             out.println("<TD>" + rs.getString("age") + "</TD>");
  52.             out.println("<TD>" + rs.getString("desig") + "</TD>");
  53.             out.println("</TR>");
  54.         }
  55.         out.println("</TABLE>");
  56.         out.println("</BODY>");
  57.     }
  58.     catch(Exception e)
  59.     {
  60.         out.println(e.toString());
  61.     }
  62.     }
  63.     public void destroy()
  64.     {
  65.         try
  66.         {
  67.             i=0;
  68.             con.close();
  69.             out.close();
  70.             rs.close();
  71.         }
  72.     catch (SQLException se)
  73.     {
  74.         out.println(se.toString());
  75.     }
  76.     }
  77. }

what i do????
Jul 13 '10 #1
2 2274
kleach
15
> java-class not found

Java classes are found by setting the CLASSPATH variable correctly. On Unix these are in the instance user's home directory, under sqllib/java.
Jul 13 '10 #2
yes sir...i have 2 zip files there...db2java.zip and sqll.zip....but i am working with netbeans...and when i put these files in src folder of project in netbeans it do not take it..as we cannot setpath with netbeans as i think...and by the runtime field of netbeans connection with db2 is done....but not through servlet...i am using window XP....
Jul 14 '10 #3

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

Similar topics

2
by: Jangley | last post by:
Hi Tomcat seems to be completely ignoring any resource that I specify in an <error-page> directive in the web.xml. The same webapp works under 4.0. Is there a bug in 4.1 that I'm not aware of?...
4
by: Jun | last post by:
anyone know how this error shows? how can i solve this? LINK : error LNK2020: unresolved token (0A0000EA) _AtlBaseModule LINK : error LNK2020: unresolved token (0A0000EC) atlTraceGeneral LINK :...
7
by: flupke | last post by:
Hi, i'm getting errors with the log module concerning RotatingFileHandler. I'm using Python 2.4.3 on Windows XP SP2. This used to work in previous python versions but since i upgraded to 2.4.3...
4
donilourdu
by: donilourdu | last post by:
hi , This is doni. I am facing problem in follwing code. I am trying to encorparate ftp server. While running it shows following error. The remote server returned an error: (530) Not logged...
8
by: ajos | last post by:
hi frnds, the situation is im developing a web application in struts-- my specifications-eclipse3.2.2,struts1.1,tomcat5.5.23 mysql5.0 db. the scenario-i have a jsp page which adds the...
2
by: hbwhjack | last post by:
After I changed some reference in the menu of vba editor, it gave me the "error- please check that a valid file path was entered" when I press a command button on my form. What 's wrong with it and...
1
by: tomb | last post by:
I haven't worked with Visual C++ before, so I'm in a little over my head on a project I'm doing. I'm using VC++ 2003 unmanaged code, and I am getting this linking error that I don't understand:...
3
by: aradhanathawait | last post by:
Hi all I have installed tomcat5 server and also jdk.1.5.0 and set the classpath, path catalina_home and java_home variables. I wrote a HelloServlet.java , compiled it and copied the class file to...
1
by: brajabas | last post by:
Problem is that connecting microsoft access database shows that database is already exclusively opened by another user
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.