Update functionality

From: Mohammed Mazid (kadmazid_at_hotmail.com)
Date: 03/27/04


Date: 27 Mar 2004 02:14:28 -0800

Hi guys,

I was trying to program an application that would be used to update
the flight. Basically using a JSP form I am updating a flight and its
associated details. However, it does not do it as it cannot pass the
flightNo parameter. Therefore can anyone please suggest correction to
that please and add in a code that would work efficiently?

Here is the code snippet:

class FlightDAO
{
  void update(Flight flight)
  {
     //Assume already statements there

    // Create the UPDATE update_stmt
    PreparedStatement update_stmt = null;

    try
        {
      // Get a database connection
      connection = connectionPool.getConnectionNoWait();

      // Create SQL UPDATE statement
      update_stmt = connection.prepareStatement(UPDATE_STMT);
      update_stmt.setDate(2, flight.flightDate);
      update_stmt.setString(3, flight.destination);
      update_stmt.setTime(4, flight.arrTime);
      update_stmt.setTime(5, flight.depTime);

      // Perform the SQL UPDATE
      update_stmt.executeUpdate();

    // Handle any SQL errors
    }
        catch (SQLException se)
        {
        //Assume some catch statements
          }

  private static final String UPDATE_STMT
  = "UPDATE Flight"
  + "SET FlightDate = ?, Destination = ?, ArrivalTime = ?,
DepartureTime = ?"
  + "WHERE FlightNo = ?";
}

public class FlightService
{
  private FlightDAO flightDataAccess;

  public FlightService()
  {
    flightDataAccess = new FlightDAO();
  }

  public Flight updateFlight(String flightNo, Date flightDate, String
destination,
          Time depTime, Time arrTime)
  {
    // Create the Flight object
        Flight flight = new Flight(flightNo, flightDate, destination,
arrTime, depTime);

    // Perform the DB transaction
    flightDataAccess.update(flight);

    return flight;
  }

It is not the whole program, just part of the source code is shown.
Can anyone please show me how to pass the flightNo parameter and also
correction of the update function so that it would work in the
database?

I think there is no need to show ConnectionPool source code and so on.
 There is only update and the passing of the flightNo parameter
correction is required.

Much appreciated.



Relevant Pages

  • How to pass a checkride 101
    ... We'll have phase checks, flight tests, checkout ... and how you should interface with the examiner ... pilot or examiner. ... a correction without grabbing control from the student. ...
    (rec.aviation.student)
  • Re: Problems in a commercial flight
    ... I'm not an expert of flight. ... and the pilot was correcting every 10-20 seconds the ... seconds there was a slight correction. ... This is also normal in a crosswind landing. ...
    (rec.aviation.piloting)
  • Problems in a commercial flight
    ... I'm not an expert of flight. ... and the pilot was correcting every 10-20 seconds the ... seconds there was a slight correction. ... and trying this landing? ...
    (rec.aviation.piloting)
  • Re: Problems in a commercial flight
    ... I'm not an expert of flight. ... and the pilot was correcting every 10-20 seconds the ... seconds there was a slight correction. ... and trying this landing? ...
    (rec.aviation.piloting)
  • Re: 14-bis First Flight
    ... As part of the commemorations in Brazil, the Brazilian Air Force (FAB) ... plenty of time for correction by modern standards, ... IIRC, it was anything but inherently stable, and you were constantly having to correct its flight path. ...
    (sci.space.history)