⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modifylogdao.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      if ( rs.next() ) {        lastValue = rs.getInt("LAST_VALUE");        int minValue = rs.getInt("MIN_VALUE");        int maxValue = rs.getInt("MAX_VALUE");        int incrementBy = rs.getInt("INCREMENT_BY");        int cycle = rs.getInt("CYCLE");        if (lastValue < 0) {          Debug.println("id last value can't smaller than 0");          throw new SysException("id last value can't smaller than 0");        }        if (minValue < 0) {          Debug.println("id min value can't smaller than 0");          throw new SysException("id min value can't smaller than 0");        }        if (maxValue < 0) {          Debug.println("id max value can't smaller than 0");          throw new SysException("id max value can't smaller than 0");        }        if (incrementBy < 1) {          Debug.println("id increment value can't smaller than 1");          throw new SysException("id increment value can't smaller than 1");        }        if (cycle != 0 && cycle != 1) {          Debug.println("id cycle value error, it can be 0 or 1 only");          throw new SysException("id cycle value error, it can be 0 or 1 only");        }        if (lastValue < minValue) {          Debug.println("id value is " + lastValue + ": \n" + "id value can't smaller than min value");          throw new SysException("id value can't smaller than min value");        }        if (minValue >= maxValue) {          Debug.println("id max value must bigger than min value");          throw new SysException("id max value must bigger than min value");        }        if (lastValue > maxValue) {          if (cycle == 0) {            Debug.println("id value is " + lastValue + ": \n" + "id value exceeds max value");            throw new SysException("id value exceeds max value");          } else {            lastValue = minValue;          }        }        sql = "UPDATE WAP_SEQUENCE SET LAST_VALUE = " + (lastValue + incrementBy) + " WHERE TABLE_NAME = 'WAP_MODIFY_LOG'";        stmt.executeUpdate(sql);      }else{        sql = "INSERT INTO WAP_SEQUENCE (TABLE_NAME, LAST_VALUE, MIN_VALUE, MAX_VALUE, INCREMENT_BY, CYCLE) VALUES ('WAP_MODIFY_LOG', 2, 1, 999999999, 1, 1)";        stmt.executeUpdate(sql);      }      return lastValue;    } catch(SQLException e) {      Debug.println(sql + "\n" + "SQLException while execute getRowCountBySql method :\n" + e);      throw new SysException("SQLException while execute getRowCountBySql method :\n" + e);    } finally {      closeResultSet(rs);      closeStatement(stmt);      closeConnection(dbConnection);    }  }  protected static String getInsertSQL(ModifyLogModel model) {    String sql = "";    if (Database.dbType == DBType.ORACLE) {      sql = "INSERT INTO WAP_MODIFY_LOG (TABLE_NAME, OPERATOR_TYPE, DATA_BEFORE_MODIFY, DATA_AFTER_MODIFY, HOSTIP, MODIFY_STAFF, MODIFY_TIME, REMARK) VALUES ('"          + Function.writeDBEncode(model.getTableName()) + "', '"          + Function.writeDBEncode(model.getOperatorType()) + "', '"          + Function.writeDBEncode(model.getDataBeforeModify()) + "', '"          + Function.writeDBEncode(model.getDataAfterModify()) + "', '"          + Function.writeDBEncode(model.getHostip()) + "', '"          + Function.writeDBEncode(model.getModifyStaff()) + "', TO_DATE('"          + Function.DateToString(model.getModifyTime()) + "', 'YYYY/MM/DD HH24:MI:SS'), '"          + Function.writeDBEncode(model.getRemark()) + "')";    } else if (Database.dbType == DBType.SQLSERVER) {      sql = "INSERT INTO WAP_MODIFY_LOG (TABLE_NAME, OPERATOR_TYPE, DATA_BEFORE_MODIFY, DATA_AFTER_MODIFY, HOSTIP, MODIFY_STAFF, MODIFY_TIME, REMARK) VALUES ('"          + Function.writeDBEncode(model.getTableName()) + "', '"          + Function.writeDBEncode(model.getOperatorType()) + "', '"          + Function.writeDBEncode(model.getDataBeforeModify()) + "', '"          + Function.writeDBEncode(model.getDataAfterModify()) + "', '"          + Function.writeDBEncode(model.getHostip()) + "', '"          + Function.writeDBEncode(model.getModifyStaff()) + "', '"          + Function.DateToString(model.getModifyTime()) + "', '"          + Function.writeDBEncode(model.getRemark()) + "')";    } else if (Database.dbType == DBType.MYSQL) {      sql = "INSERT INTO WAP_MODIFY_LOG (TABLE_NAME, OPERATOR_TYPE, DATA_BEFORE_MODIFY, DATA_AFTER_MODIFY, HOSTIP, MODIFY_STAFF, MODIFY_TIME, REMARK) VALUES ('"          + Function.writeDBEncode(model.getTableName()) + "', '"          + Function.writeDBEncode(model.getOperatorType()) + "', '"          + Function.writeDBEncode(model.getDataBeforeModify()) + "', '"          + Function.writeDBEncode(model.getDataAfterModify()) + "', '"          + Function.writeDBEncode(model.getHostip()) + "', '"          + Function.writeDBEncode(model.getModifyStaff()) + "', '"          + Function.DateToString(model.getModifyTime()) + "', '"          + Function.writeDBEncode(model.getRemark()) + "')";    }    return sql;  }  protected static boolean isValidData(ModifyLogModel model) {    return true;  }  private static Connection getDBConnection() throws SysException {    return Database.getConnection();  }  private static void closeConnection(Connection dbConnection) throws SysException {    try {      if (dbConnection != null && !dbConnection.isClosed()) {        dbConnection.close();        dbConnection = null;      }    } catch (SQLException se) {      //throw new SysException("SQL Exception while closing DB connection : \n" + se);    }  }  private static void closeResultSet(ResultSet result) throws SysException {    try {      if (result != null) {        result.close();      }    } catch (SQLException se) {      //throw new SysException("SQL Exception while closing Result Set : \n" + se);    }  }  private static void closeStatement(Statement stmt) throws SysException {    try {      if (stmt != null) {        stmt.close();      }    } catch (SQLException se) {      //throw new SysException("SQL Exception while closing Statement : \n" + se);    }  }  public static void main(String[] args) throws Exception{    String action = "";    if (args.length == 1) {      action = args[0];    }    if (action == null || "".equals(action)) {    } else if ("insert".equalsIgnoreCase(action)) {      ModifyLogModel model=new ModifyLogModel();      model.setTableName("abc");      model.setOperatorType("abc");      model.setDataBeforeModify("abc");      model.setDataAfterModify("abc");      model.setHostip("abc");      model.setModifyStaff("abc");      model.setModifyTime(Function.getCurrTime());      model.setRemark("abc");      ModifyLogModel modifyLogModel = ModifyLogBean.insert(model);    }else if ("queryBySql".equalsIgnoreCase(action)){      Collection coll = ModifyLogBean.queryBySql("SELECT * FROM WAP_MODIFY_LOG");    }else if ("getRowCountBySql".equalsIgnoreCase(action)){      int rowCount = ModifyLogBean.getRowCountBySql("SELECT COUNT(*) FROM WAP_MODIFY_LOG");      System.out.println("rowCount = " + rowCount);    }else if ("queryAll".equalsIgnoreCase(action)){      Collection coll = ModifyLogBean.queryAll();      Iterator it = coll.iterator();      while ( it.hasNext() ) {        Hashtable element = (Hashtable)it.next();        String tableName = (String)element.get("tableName");        String operatorType = (String)element.get("operatorType");        String dataBeforeModify = (String)element.get("dataBeforeModify");        String dataAfterModify = (String)element.get("dataAfterModify");        String hostip = (String)element.get("hostip");        String modifyStaff = (String)element.get("modifyStaff");        String modifyTime = Function.getYYYYMMDDHHMISS((Timestamp)element.get("modifyTime"));        String remark = (String)element.get("remark");        System.out.print("tableName = " + tableName + ",\t");        System.out.print("operatorType = " + operatorType + ",\t");        System.out.print("dataBeforeModify = " + dataBeforeModify + ",\t");        System.out.print("dataAfterModify = " + dataAfterModify + ",\t");        System.out.print("hostip = " + hostip + ",\t");        System.out.print("modifyStaff = " + modifyStaff + ",\t");        System.out.print("modifyTime = " + modifyTime + ",\t");        System.out.print("remark = " + remark + "\n");      }    }else if ("getRowCountOfAll".equalsIgnoreCase(action)){      int rowCount = ModifyLogBean.getRowCountOfAll();      System.out.println("rowCount = " + rowCount);    }  }}/*String tableName = (model==null?"":model.getTableName());String operatorType = (model==null?"":model.getOperatorType());String dataBeforeModify = (model==null?"":model.getDataBeforeModify());String dataAfterModify = (model==null?"":model.getDataAfterModify());String hostip = (model==null?"":model.getHostip());String modifyStaff = (model==null?"":model.getModifyStaff());Timestamp modifyTime = (model==null?null:model.getModifyTime());String remark = (model==null?"":model.getRemark());String tableName = PageUtil.parseStringField(request.getParameter("tableName"), "tableName", false, 49);String operatorType = PageUtil.parseStringField(request.getParameter("operatorType"), "operatorType", false, 9);String dataBeforeModify = PageUtil.parseStringField(request.getParameter("dataBeforeModify"), "dataBeforeModify", false, 254);String dataAfterModify = PageUtil.parseStringField(request.getParameter("dataAfterModify"), "dataAfterModify", false, 254);String hostip = PageUtil.parseStringField(request.getParameter("hostip"), "hostip", false, 19);String modifyStaff = PageUtil.parseStringField(request.getParameter("modifyStaff"), "modifyStaff", false, 19);String remark = PageUtil.parseStringField(request.getParameter("remark"), "remark", false, 254);String tableName = PageUtil.parseStringField(request.getParameter("tableName"), "tableName", true, 50);String operatorType = PageUtil.parseStringField(request.getParameter("operatorType"), "operatorType", true, 10);String dataBeforeModify = PageUtil.parseStringField(request.getParameter("dataBeforeModify"), "dataBeforeModify", true, 255);String dataAfterModify = PageUtil.parseStringField(request.getParameter("dataAfterModify"), "dataAfterModify", true, 255);String hostip = PageUtil.parseStringField(request.getParameter("hostip"), "hostip", true, 20);String modifyStaff = PageUtil.parseStringField(request.getParameter("modifyStaff"), "modifyStaff", true, 20);Timestamp modifyTime = PageUtil.parseDateField(request.getParameter("modifyTime"), "modifyTime", true);String remark = PageUtil.parseStringField(request.getParameter("remark"), "remark", true, 255);String tableName = (model==null?"":""+model.getTableName());String operatorType = (model==null?"":""+model.getOperatorType());String dataBeforeModify = (model==null?"":""+model.getDataBeforeModify());String dataAfterModify = (model==null?"":""+model.getDataAfterModify());String hostip = (model==null?"":""+model.getHostip());String modifyStaff = (model==null?"":""+model.getModifyStaff());Timestamp modifyTime = (model==null?null:model.getModifyTime());String remark = (model==null?"":""+model.getRemark());Collection coll = ModifyLogBean.queryAll((pageNum-1) * pageRow + 1, pageNum * pageRow);Iterator it = coll.iterator();while ( it.hasNext() ) {    Hashtable element = (Hashtable)it.next();    ModifyLogModel modifyLogModel = ModifyLogBean.toModel(element);    String tableName = modifyLogModel.getTableName();    String operatorType = modifyLogModel.getOperatorType();    String dataBeforeModify = modifyLogModel.getDataBeforeModify();    String dataAfterModify = modifyLogModel.getDataAfterModify();    String hostip = modifyLogModel.getHostip();    String modifyStaff = modifyLogModel.getModifyStaff();    Timestamp modifyTime = modifyLogModel.getModifyTime();    String remark = modifyLogModel.getRemark();        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), tableName+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), operatorType+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), dataBeforeModify+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), dataAfterModify+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), hostip+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), modifyStaff+"");        excel.setCellData(new ExcelCell(ExcelUtil.DATE_CELL_TYTE,   currRow, currCol++), modifyTime);        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), remark+"");*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -