Exemple #1
0
 public static void main(String[] args) {
   try {
     Connection con = DBopsMySql.setuptradesConnection();
     con.setAutoCommit(false);
     String ul = "AUD";
     PreparedStatement pstmt = DBopsMySql.getExpirysForUpdate(con, ul, 20090300, 20100700);
     PreparedStatement upDateStmt = DBopsMySql.updateBeginEndDatesForExpiry(con);
     ResultSet res = pstmt.executeQuery();
     res.next(); // To get a lastexpiry for loop, so should be one extra early expiry
     int lastexp = res.getInt("expiry");
     while (res.next()) {
       int exp = res.getInt("expiry");
       String bdate = DateOps.dbShortFormatString(lastexp - 5);
       String edate = DateOps.dbShortFormatString(exp - 6);
       upDateStmt.setString(1, bdate);
       if (!res.isLast()) {
         upDateStmt.setString(2, edate);
       }
       upDateStmt.setString(3, ul);
       upDateStmt.setInt(4, exp);
       upDateStmt.addBatch();
       lastexp = exp;
     }
     int[] updateCounts = upDateStmt.executeBatch();
     upDateStmt.close();
     con.close();
   } catch (SQLException ex) {
     MsgBox.err2(ex);
   }
 }