示例#1
0
  /**
   * Method to build a vector from a ResultSet
   *
   * @param <code>ResultSet rsResult</code> the result from a query
   * @return Vector of objects from the ResultSet
   * @exception Throws Exception on error
   */
  protected Vector buildObjectVector(ResultSet rsResult) throws Exception {
    // vector for return data
    Vector vReturn = null;

    try {
      // init the vector
      vReturn = new Vector(super.VECT_INIT_SIZE, super.VECT_GROW_SIZE);

      // loop through the entire result set
      while (rsResult.next()) {
        // create a new one
        StageUsacForm objTmp = new StageUsacForm();

        // set the attributes
        // ADDING A NEW FIELD "ROWID"
        objTmp.ROWID = rsResult.getString("ROWID");

        objTmp.HDR_SPIN = rsResult.getLong("HDR_SPIN");
        objTmp.SPIN_NM = rsResult.getString("SPIN_NM");
        objTmp.RCPNT_EMAIL = rsResult.getString("RCPNT_EMAIL");
        objTmp.USAC_EMAIL = rsResult.getString("USAC_EMAIL");
        objTmp.RFRNC_NMBR = rsResult.getString("RFRNC_NMBR");
        objTmp.RCRD_CNT = rsResult.getLong("RCRD_CNT");
        objTmp.TOT_PAYMENT = rsResult.getDouble("TOT_PAYMENT");
        objTmp.USAC_PRCS_DAT = rsResult.getDate("USAC_PRCS_DAT");
        objTmp.RTRCT_FLAG = rsResult.getString("RTRCT_FLAG");
        objTmp.DTL_SPIN = rsResult.getLong("DTL_SPIN");
        objTmp.FRN = rsResult.getLong("FRN");
        objTmp.SDC_INV_NO = rsResult.getString("SDC_INV_NO");
        objTmp.AMT_PAID = rsResult.getDouble("AMT_PAID");
        objTmp.DSBRSMNT_TXT = rsResult.getString("DSBRSMNT_TXT");
        objTmp.EMAIL_DATE = rsResult.getDate("EMAIL_DATE");
        objTmp.FILENAME = rsResult.getString("FILENAME");
        objTmp.PROCESS_DATE = rsResult.getDate("PROCESS_DATE");
        objTmp.STATUS = rsResult.getLong("STATUS");

        // add it to the vector
        vReturn.addElement(objTmp);
      }

      return vReturn;
    } catch (Exception e) {
      throw new Exception("BuildObjectVector()\n" + e.getMessage());
    }
  }
示例#2
0
  public static List<Movie> getAllMovies() {
    String query = "SELECT * FROM movie";
    List<Movie> movies = new LinkedList<>();
    try (Connection connection = Config.getConnection(); // step 1
        Statement statement = connection.createStatement(); // step 2
        ResultSet result = statement.executeQuery(query); ) { // step 3 and 4
      while (result.next()) { // step 5
        Movie movie = new Movie();
        // you should be validating the following,
        // this is just an example to get you started
        movie.setName(result.getString(1));
        movie.setYear(result.getDate(2).getYear());
        movie.setUrl(result.getString(3));
        movies.add(movie);
      }
    } catch (SQLException e) {
      System.err.println(e.getMessage());
      System.err.println(e.getStackTrace());
    }

    return movies;
  }