Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Re: Difficulty in compiling a servlet.

anunay ashish

2003-10-13

Replies:

I don't have a syntax error any where.
----- Original Message -----
From: "Eric C" <chabere@(protected)>
To: "Tomcat Users List" <tomcat-user@(protected)>
Sent: Sunday, October 12, 2003 2:00 PM
Subject: Re: Difficulty in compiling a servlet.


> Don't you have a syntax error somewhere ?
>
> DBUpadate
>
>
>
> ----- Original Message -----
> From: "anunay ashish" <anunaya@(protected)>
> To: "Tomcat Users List" <tomcat-user@(protected)>
> Sent: Saturday, October 11, 2003 2:27 PM
> Subject: Difficulty in compiling a servlet.
>
>
> > Hi,
> >
> > The code for my bean is:
> >
> > package com.scheduler;
> > import java.sql.*;
> > public class DBUpdate
> > {
> >   private Connection conn;
> >   private Statement stmt;
> >   private ResultSet rs;
> > public DBUpdate()
> >   {
> >      conn = null;
> >      stmt = null;
> >      rs = null;
> >   }
> > public void process(String query)
> >   {
> >      try
> >      {
> >
> Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
> >         Connection conn =
> >
DriverManager.getConnection("jdbc:oracle:thin:@(protected)",
> > "mangesh", "mangesh");
> >         stmt = conn.createStatement();
> >         rs = stmt.executeQuery(query);
> >   System.out.println("Query: " + query + " executed");
> >      }
> >      catch(Exception exception1)
> >      {
> >         System.out.println("Error occured in DBUpdate.process()
> > SQLException :" + exception1);
> >      }
> >   }
> > public ResultSet getResultSet() throws SQLException
> >   {
> >    return rs;
> >   }
> > public void destroy()
> > {
> >      conn = null;
> >      stmt = null;
> >      rs = null;
> > }
> > }
> >
> > And for my servlet is:
> >
> > package com.scheduler;
> > import java.io.*;
> > import java.sql.*;
> > import java.text.*;
> > import java.util.*;
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> >
> > public class addDataServlet extends HttpServlet
> > {
> > private String pageFormat;
> > public void doPost(HttpServletRequest request, HttpServletResponse
> > response) throws ServletException, IOException
> > {
> >  ResultSet testRS;
> >  DBUpdate dbupdate = new DBUpdate();
> >  pageFormat = request.getParameter("newPageFormat");
> >  PrintWriter out = response.getWriter();
> >  out.print(pageFormat);
> >  String query = "Select * from lookup_page_format";
> >  dbupdate.process(query);
> >  try
> >  {
> >   testRS = dbupdate.getResultSet();
> >     while(testRS.next())
> >   {
> >   out.print(testRS.getString(2));
> >   out.print("hi");
> >   }
> >  }
> >  catch (SQLException e)
> >  {
> >   out.println("SQLException :" + e);
> >  }
> >  try
> >  {
> >   //set the attribute and forward to pageFormat.jsp
> >   request.setAttribute("servletName", "addDataServlet");
> >
> >
>
getServletConfig().getServletContext().getRequestDispatcher("/Tracking_syste
> > m/pageFormat.jsp").forward(request, response);
> >  }
> >  catch (Exception ex)
> >  {
> >   ex.printStackTrace ();
> >  }
> > }
> > }
> >
> > On compiling the addDataServlet.java, an error is coming - Unresolved
> > symbol:Class DBUpadate is not resolved
> > Where I am doing wrong?
> >
> > Thanks in advance.
> > Regards,
> > Anunay.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
> > For additional commands, e-mail: tomcat-user-help@(protected)
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
> For additional commands, e-mail: tomcat-user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.