Exemple #1
0
  /**
   * This method Inserts Journal Dates in BLG_PRD table.
   *
   * @exception SQLException, if Insertion fails
   * @author
   */
  public boolean insertJrnldts(
      String bpid,
      String blgsys,
      String rgn,
      String strtdt,
      String enddt,
      String month,
      String year) {
    String query;
    boolean insert_flag = false;
    PreparedStatement pstmt = null;

    query =
        "Insert into blg_prd (bp_id,bs_id_fk,bp_year,bp_month,bp_strt_dat,bp_end_dat,bp_rgn) values ";
    query = query + "(?,?,?,?,to_date(?,'MM/DD/YYYY') ,to_date(?,'MM/DD/YYYY') ,?) ";

    USFEnv.getLog().writeDebug("Dinvjrnl:Insertion - Query" + query, this, null);

    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, bpid);
      pstmt.setString(2, blgsys);
      pstmt.setString(3, year);
      pstmt.setString(4, month);
      pstmt.setString(5, strtdt);
      pstmt.setString(6, enddt);
      pstmt.setString(7, rgn);

      insert_flag = (pstmt.executeUpdate() != 0) ? true : false;
      if (pstmt != null) pstmt.close();
      return insert_flag;
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: The Insertion of Journal Dates failed", this, ex);
      try {
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }
    return false;
  }
Exemple #2
0
  /**
   * This method updates the BLG_PRD table.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public boolean updateJrnldts(String bpid, String strtdt, String enddt) {
    String query;
    boolean update_flag = false;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query =
        "update blg_prd set bp_strt_dat=to_date(?,'MM/DD/YYYY') , bp_end_dat=to_date(?,'MM/DD/YYYY') where bp_id = ?";

    USFEnv.getLog().writeDebug("Dinvjrnl:Updation- Query" + query, this, null);

    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, strtdt);
      pstmt.setString(2, enddt);
      pstmt.setString(3, bpid);

      update_flag = (pstmt.executeUpdate() != 0) ? true : false;
      if (pstmt != null) pstmt.close();
      return update_flag;
    } catch (SQLException ex) {
      try {
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
        USFEnv.getLog().writeCrit("Unable to close statement", this, e);
      }
      USFEnv.getLog().writeCrit("Dinvjrnl: The Updation of Journal Dates failed", this, ex);
    } catch (Exception e) {
      try {
        if (pstmt != null) pstmt.close();
      } catch (Exception ex) {
        USFEnv.getLog().writeCrit("Unable to close statement", this, ex);
      }

      USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
    }

    return false;
  }