Ejemplo n.º 1
1
  private String getMonth(String month) {
    String query;
    String i_month = "";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    query = "select to_number(to_char(to_date(?,'Month'),'MM')) from dual";

    USFEnv.getLog().writeDebug("Dinvjrnl:Get Month - Query" + query, this, null);
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, month);

      rs = pstmt.executeQuery();
      if (rs.next()) {
        i_month = rs.getString(1);
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: Month Conversion Failed ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return i_month;
  }
Ejemplo n.º 2
1
  public Vector getUsacFiles(String invoice) {
    Vector fileList = new Vector();
    String query = "";

    query =
        query
            + " SELECT distinct filename, '  Date:'||to_char(usac_prcs_dat,'MM/DD/YYYY'),trunc(usac_prcs_dat) usac_prcs_dat ";
    query = query + " FROM stage_usac_form ";
    query = query + " WHERE rtrim(ltrim(sdc_inv_no)) = ?";
    query = query + " ORDER BY usac_prcs_dat ";

    USFEnv.getLog().writeDebug("getUsacFiles() Query :" + query, this, null);

    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = cConn.prepareStatement(query);
      pstmt.setString(1, invoice);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        fileList.addElement(rs.getString(1));
        fileList.addElement(rs.getString(2));
      }

      // rs.close();
      // stmt.close();
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();

    } catch (SQLException ex) {
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
        USFEnv.getLog().writeCrit("Unable to close ResultSet and statement", this, e);
      }
      USFEnv.getLog().writeCrit("getUsacFiles() Failed Query:" + query, this, ex);
    }

    /*	try
    {
    	if( rs != null)
    		rs.close();
    }
    catch(Exception e)
    {
    	USFEnv.getLog().writeCrit("Unable to close ResultSet",this,null);
    }
    try
    {
    	if( pstmt != null)
    		pstmt.close();
    }
    catch(Exception e)
    {
    USFEnv.getLog().writeCrit("Unable to close Prepared Statement",this,null);
    }*/
    return fileList;
  }
Ejemplo n.º 3
0
  /**
   * This method queries the database to get the details related to the bp_id passed.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public Vector getBpdet(String bpid) {
    String query;
    Vector bpdet = new Vector();
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select rtrim(bs_id_fk||bp_rgn),bp_month from blg_prd where bp_id = ?";

    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, bpid);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        bpdet.addElement(rs.getString(1));
        bpdet.addElement(rs.getString(2));
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: BP_ID details not Retreived ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return bpdet;
  }
Ejemplo n.º 4
0
  /**
   * This method queries the database to get the list of the Billing Systems.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public Vector getYears(String year) {
    String query;
    Vector years = new Vector();
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select yr||'-'||(yr+1),yr from fung_yr where yr > ?";

    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, year);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        years.addElement(rs.getString(1));
        years.addElement(rs.getString(2));
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: Years List not Retreived ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return years;
  }
Ejemplo n.º 5
0
  /**
   * This method queries the database to get the name of the Billing System.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public String getBlgsysnm(String blgsys) {
    String query;
    String blgsysnm = "";
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select bs_nm from blg_sys where bs_id = ?";

    USFEnv.getLog().writeDebug("Dinvjrnl: Billing System Name Query :" + query, this, null);
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, blgsys);

      rs = pstmt.executeQuery();
      if (rs.next()) {
        blgsysnm = rs.getString(1);
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: Billing System Name not Retreived ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepare statement", this, e);
      }
    }

    return blgsysnm;
  }
Ejemplo n.º 6
0
  /**
   * This method queries the database to check if the passed start date for the Journal Month starts
   * exactly after the Previous end date.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public boolean check(String strtdat, String blgsys, String year, String month, String rgn) {
    if (month.length() > ((new Integer("2")).intValue())) {
      month = getMonth(month);
    }

    String query;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select 'true' from (select bp_end_dat,bp_year from blg_prd ";
    query = query + "where bp_month= decode(to_number(?),1,12,to_number(?)-1) and bs_id_fk = ?";

    if ((rgn != null) && !(rgn.equals(""))) {
      query = query + " and bp_rgn = ?";
    } else {
      query = query + " and bp_rgn is null";
    }

    query = query + " and bp_year=decode(to_number(?),1,to_number(?)-1,to_number(?) ) ) A ";

    query = query + " where to_date(?,'MM/DD/YYYY')-A.bp_end_dat=1";

    USFEnv.getLog().writeDebug("Dinvjrnl:check Date- Query" + query, this, null);
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, month);
      pstmt.setString(2, month);
      pstmt.setString(3, blgsys);

      int m = 4;
      if ((rgn != null) && !(rgn.equals(""))) {
        pstmt.setString(m, rgn);
        m = m + 1;
      }

      pstmt.setString(m, month);
      pstmt.setString(m + 1, year);
      pstmt.setString(m + 2, year);
      pstmt.setString(m + 3, strtdat);

      rs = pstmt.executeQuery();

      if (rs.next()) {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
        return true;
      }
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: Date Check Failed ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return false;
  }
Ejemplo n.º 7
0
  /**
   * This method queries the database to get the Journal Dates for the passed in Funding Year
   *
   * @exception SQLException, if query fails
   * @author
   */
  public Vector getJrnldts(String year) {
    String query;
    Vector jrnllst = new Vector();
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query =
        "select bp_id,decode(bs_nm,'CRIS','1','IABS','2','BART','3','SOFI','4','INFRANET','5','6') ord, ";
    query = query + "rtrim(bs_nm||' '||bp_rgn) nm, bp_month,decode(bp_month,1,'January',";
    query =
        query
            + "2,'February',3,'March',4,'April',5,'May',6,'June',7,'July',8,'August',9,'September',";
    query =
        query
            + "10,'October',11,'November',12,'December'), to_char(bp_strt_dat,'MM/DD/YYYY'),to_char(bp_end_dat,'MM/DD/YYYY') ";
    query = query + "from blg_prd,blg_sys ";
    query = query + "where bs_id=bs_id_fk and ( bp_strt_dat >= ";
    query = query + "(select strt_dat from fung_yr where yr = ?) and ";
    query = query + "bp_end_dat <= (select end_dat from fung_yr where yr = ?) ";
    query = query + "or ( bp_year =to_number(?) and bp_month=7) ) ";
    query = query + "order by ord,nm,bp_strt_dat ";

    USFEnv.getLog().writeDebug("Dinvjrnl: JRNL Dates Query :" + query, this, null);
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, year);
      pstmt.setString(2, year);
      pstmt.setString(3, year);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        Dinvjrnl jrnldts = new Dinvjrnl(null);

        jrnldts.strBpid = rs.getString(1);
        jrnldts.strBlgsys = rs.getString(3);
        jrnldts.strBlgmnth = rs.getString(5);
        jrnldts.strBlgstrtdt = rs.getString(6);
        jrnldts.strBlgenddt = rs.getString(7);

        jrnllst.addElement(jrnldts);
        jrnldts = null;
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: JRNL Dates not retreived for the Year ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    USFEnv.getLog()
        .writeDebug("Dinvjrnl: Journal Dates Vector size :" + jrnllst.size(), this, null);
    return jrnllst;
  }
Ejemplo n.º 8
0
  /**
   * This method queries the database to get the sequence for the BP_ID.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public boolean checkDuplicate(String blgsys, String year, String month, String rgn) {
    String query;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select 'true' from blg_prd where bs_id_fk=" + blgsys + " and bp_year=" + year;
    query = query + " and bp_month=" + month;

    if ((rgn != null) && !(rgn.equals(""))) {
      query = query + " and bp_rgn='" + rgn + "'";
    } else {
      query = query + " and bp_rgn is null";
    }

    USFEnv.getLog().writeDebug("Dinvjrnl:check Duplicate- Query" + query, this, null);
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, blgsys);
      pstmt.setString(2, year);
      pstmt.setString(3, month);
      if ((rgn != null) && !(rgn.equals(""))) {
        pstmt.setString(4, rgn);
      }

      rs = pstmt.executeQuery();
      if (rs.next()) {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
        return true;
      }
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: Date Comparison Failed ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return false;
  }
Ejemplo n.º 9
0
  /**
   * This method queries the database to get the sequence for the BP_ID.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public boolean checkDates(String strtdt, String enddt, String year) {
    String query;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select 'true' from fung_yr where to_date(?,'MM/DD/YYYY') < to_date(?,'MM/DD/YYYY') ";
    query = query + "and yr = ? and strt_dat-10 <= to_date(?,'MM/DD/YYYY') ";
    query = query + "and end_dat >= to_date(?,'MM/DD/YYYY')  ";

    USFEnv.getLog().writeDebug("Dinvjrnl: Check Dates Query :" + query, this, null);
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, strtdt);
      pstmt.setString(2, enddt);
      pstmt.setString(3, year);
      pstmt.setString(4, strtdt);
      pstmt.setString(5, enddt);

      rs = pstmt.executeQuery();
      if (rs.next()) {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
        return true;
      }
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: Date Comparison Failed ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return false;
  }
Ejemplo n.º 10
0
  /**
   * This method searches the tables FRNS, FRN_DETS, FRN_DET_HSTIES for the presence of a record in
   * a specific query. It returns the invoice line number.
   *
   * @param <code>StageUsacForm</code> The STAGE_USAC object.
   * @return long containing the invoice line number.
   */
  public long searchForAmount(java.sql.Connection conn) {
    // the buffer for the query
    StringBuffer sbQuery = null;
    long returnAmt = 0;
    // Vector invline=null;

    PreparedStatement psStmt = null;
    ResultSet rsResult = null;
    try {
      // init the buffer
      sbQuery = new StringBuffer("");

      // build the query
      sbQuery.append("SELECT max(INV_LN_NO) AS INV_LN_NO_MAX ");
      sbQuery.append("FROM (SELECT sum(CRDT_AMT) AMT, INV_LN_NO ");
      sbQuery.append("FROM FRNS, FRN_DETS, FRN_DET_HSTIES, INV ");
      sbQuery.append("WHERE ");
      sbQuery.append("FRN_ID=FRN_ID_FK AND FD_ID=FD_ID_FK AND INV_STAT='I' AND ");
      sbQuery.append("INV_ID_FK=INV_ID");
      // sbQuery.append(" AND FRN = ?'");
      sbQuery.append(" AND FRN = ? ");
      // sbQuery.append(this.getFrn());
      // sbQuery.append("' GROUP BY INV_LN_NO) " );
      sbQuery.append(" GROUP BY INV_LN_NO) ");
      sbQuery.append(" WHERE AMT = ?");
      // sbQuery.append(this.getAmtPaid());

      // write to log if in debug mode
      USFEnv.getLog()
          .writeDebug(
              "searchForAmount(StageUsacForm) " + "sbQuery is " + sbQuery.toString() + "\n",
              this,
              null);

      psStmt = conn.prepareStatement(sbQuery.toString());

      // psStmt.setLong(1,this.getFrn());
      psStmt.setString(1, String.valueOf(this.getFrn()));
      psStmt.setDouble(2, this.getAmtPaid());

      rsResult = psStmt.executeQuery();

      if (rsResult.next()) {
        returnAmt = rsResult.getLong(1);
      }
      if (rsResult != null) rsResult.close();
      if (psStmt != null) psStmt.close();

    } catch (Exception e) {
      try {
        if (rsResult != null) rsResult.close();
        if (psStmt != null) psStmt.close();
      } catch (Exception ex) {
        USFEnv.getLog().writeCrit("Unable to close ResultSet and statement", this, ex);
      }
      USFEnv.getLog()
          .writeCrit("searchForAmount(StageUsacForm) Failed Query:" + sbQuery.toString(), this, e);
    }

    /*	try
    {
    	if( rsResult != null)
    		rsResult.close();
    }
    catch(Exception e)
    {
    	USFEnv.getLog().writeCrit("Unable to close ResultSet",this,null);
    }
    try
    {
    	if( psStmt != null)
    		psStmt.close();
    }
    catch(Exception e)
    {
    	 USFEnv.getLog().writeCrit("Unable to close Prepared Statement",this,null);
    }*/

    return (returnAmt);
  } // searchForAmount
Ejemplo n.º 11
0
  /**
   * This method searches the table STAGE_USAC_FORM for the distinctfilename provided for the usac
   * refrence number given
   *
   * @param Stringusac refrence number
   * @return Vector containing the Result Set
   */
  public Vector selectFileName(String rfrnc_nmbr) {
    // the buffer for the query
    StringBuffer sbQuery = null;
    Vector rsVector = new Vector();
    PreparedStatement psStmt = null;
    ResultSet rsResult = null;

    try {
      // init the buffer
      sbQuery = new StringBuffer("");
      // build the query
      sbQuery.append(buildSelectFileName());
      sbQuery.append(" WHERE ");
      sbQuery.append(" rfrnc_nmbr = ?");
      // sbQuery.append( rfrnc_nmbr );
      // sbQuery.append("'");

      USFEnv.getLog()
          .writeDebug(
              "Get FileName by USAC Ref Number  is: " + sbQuery.toString() + "\n", this, null);

      // execute the query
      psStmt = cConn.prepareStatement(sbQuery.toString());
      psStmt.setString(1, rfrnc_nmbr);

      rsResult = psStmt.executeQuery();
      if (rsResult != null) {
        while (rsResult.next()) {
          rsVector.addElement(rsResult.getString("FILENAME"));
          USFEnv.getLog()
              .writeDebug(" THE FILENAME IS : " + rsResult.getString("FILENAME"), this, null);
        }
      }

      if (rsResult != null) rsResult.close();
      if (psStmt != null) psStmt.close();

    } catch (SQLException e) {
      try {
        // close the statment and the ResultSet
        if (rsResult != null) rsResult.close();
        if (psStmt != null) psStmt.close();
      } catch (SQLException ex) {
        USFEnv.getLog()
            .writeCrit("selectSQLCall(): Fail to close result set or prepare statement", this, ex);
      }
      USFEnv.getLog()
          .writeCrit(
              " SQL Exception : SQL Error message "
                  + e.getMessage()
                  + " with Query: \n"
                  + sbQuery.toString(),
              this,
              e);
    } catch (Exception e) {
      try {
        // close the statment and the ResultSet
        if (rsResult != null) rsResult.close();
        if (psStmt != null) psStmt.close();
      } catch (SQLException ex) {
        USFEnv.getLog()
            .writeCrit("selectSQLCall(): Fail to close result set or prepare statement", this, ex);
      }
      USFEnv.getLog()
          .writeCrit(
              "Error Executing the Query(): Error executing query " + e.getMessage(), this, e);
    }

    /* try
      {
             // close the statment and the ResultSet
             if (rsResult != null)
             rsResult.close();
             if (psStmt != null)
             psStmt.close();
      }
      catch (SQLException e)
      {
    USFEnv.getLog().writeCrit("selectSQLCall(): Fail to close result set or prepare statement",this, e);
      }*/

    return rsVector;
  }