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

📄 usercarddao.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        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_USER_CARD'";        stmt.executeUpdate(sql);      }else{        sql = "INSERT INTO WAP_SEQUENCE (TABLE_NAME, LAST_VALUE, MIN_VALUE, MAX_VALUE, INCREMENT_BY, CYCLE) VALUES ('WAP_USER_CARD', 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(UserCardModel model) {    String sql = "";    if (Database.dbType == DBType.ORACLE) {      sql = "INSERT INTO WAP_USER_CARD (USER_MDN, USER_NAME, USER_JOB, USER_COM, USER_TEL, USER_FAX, USER_EMAIL, USER_ADRESS, USER_POST) VALUES ('"          + Function.writeDBEncode(model.getUserMdn()) + "', '"          + Function.writeDBEncode(model.getUserName()) + "', '"          + Function.writeDBEncode(model.getUserJob()) + "', '"          + Function.writeDBEncode(model.getUserCom()) + "', '"          + Function.writeDBEncode(model.getUserTel()) + "', '"          + Function.writeDBEncode(model.getUserFax()) + "', '"          + Function.writeDBEncode(model.getUserEmail()) + "', '"          + Function.writeDBEncode(model.getUserAdress()) + "', '"          + Function.writeDBEncode(model.getUserPost()) + "')";    } else if (Database.dbType == DBType.SQLSERVER) {      sql = "INSERT INTO WAP_USER_CARD (USER_MDN, USER_NAME, USER_JOB, USER_COM, USER_TEL, USER_FAX, USER_EMAIL, USER_ADRESS, USER_POST) VALUES ('"          + Function.writeDBEncode(model.getUserMdn()) + "', '"          + Function.writeDBEncode(model.getUserName()) + "', '"          + Function.writeDBEncode(model.getUserJob()) + "', '"          + Function.writeDBEncode(model.getUserCom()) + "', '"          + Function.writeDBEncode(model.getUserTel()) + "', '"          + Function.writeDBEncode(model.getUserFax()) + "', '"          + Function.writeDBEncode(model.getUserEmail()) + "', '"          + Function.writeDBEncode(model.getUserAdress()) + "', '"          + Function.writeDBEncode(model.getUserPost()) + "')";    } else if (Database.dbType == DBType.MYSQL) {      sql = "INSERT INTO WAP_USER_CARD (USER_MDN, USER_NAME, USER_JOB, USER_COM, USER_TEL, USER_FAX, USER_EMAIL, USER_ADRESS, USER_POST) VALUES ('"          + Function.writeDBEncode(model.getUserMdn()) + "', '"          + Function.writeDBEncode(model.getUserName()) + "', '"          + Function.writeDBEncode(model.getUserJob()) + "', '"          + Function.writeDBEncode(model.getUserCom()) + "', '"          + Function.writeDBEncode(model.getUserTel()) + "', '"          + Function.writeDBEncode(model.getUserFax()) + "', '"          + Function.writeDBEncode(model.getUserEmail()) + "', '"          + Function.writeDBEncode(model.getUserAdress()) + "', '"          + Function.writeDBEncode(model.getUserPost()) + "')";    }    return sql;  }  protected static boolean isValidData(UserCardModel 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)) {      UserCardModel model=new UserCardModel();      model.setUserMdn("abc");      model.setUserName("abc");      model.setUserJob("abc");      model.setUserCom("abc");      model.setUserTel("abc");      model.setUserFax("abc");      model.setUserEmail("abc");      model.setUserAdress("abc");      model.setUserPost("abc");      UserCardModel userCardModel = UserCardBean.insert(model);    }else if ("queryBySql".equalsIgnoreCase(action)){      Collection coll = UserCardBean.queryBySql("SELECT * FROM WAP_USER_CARD");    }else if ("getRowCountBySql".equalsIgnoreCase(action)){      int rowCount = UserCardBean.getRowCountBySql("SELECT COUNT(*) FROM WAP_USER_CARD");      System.out.println("rowCount = " + rowCount);    }else if ("queryAll".equalsIgnoreCase(action)){      Collection coll = UserCardBean.queryAll();      Iterator it = coll.iterator();      while ( it.hasNext() ) {        Hashtable element = (Hashtable)it.next();        String userMdn = (String)element.get("userMdn");        String userName = (String)element.get("userName");        String userJob = (String)element.get("userJob");        String userCom = (String)element.get("userCom");        String userTel = (String)element.get("userTel");        String userFax = (String)element.get("userFax");        String userEmail = (String)element.get("userEmail");        String userAdress = (String)element.get("userAdress");        String userPost = (String)element.get("userPost");        System.out.print("userMdn = " + userMdn + ",\t");        System.out.print("userName = " + userName + ",\t");        System.out.print("userJob = " + userJob + ",\t");        System.out.print("userCom = " + userCom + ",\t");        System.out.print("userTel = " + userTel + ",\t");        System.out.print("userFax = " + userFax + ",\t");        System.out.print("userEmail = " + userEmail + ",\t");        System.out.print("userAdress = " + userAdress + ",\t");        System.out.print("userPost = " + userPost + "\n");      }    }else if ("getRowCountOfAll".equalsIgnoreCase(action)){      int rowCount = UserCardBean.getRowCountOfAll();      System.out.println("rowCount = " + rowCount);    }  }}/*String userMdn = (model==null?"":model.getUserMdn());String userName = (model==null?"":model.getUserName());String userJob = (model==null?"":model.getUserJob());String userCom = (model==null?"":model.getUserCom());String userTel = (model==null?"":model.getUserTel());String userFax = (model==null?"":model.getUserFax());String userEmail = (model==null?"":model.getUserEmail());String userAdress = (model==null?"":model.getUserAdress());String userPost = (model==null?"":model.getUserPost());String userMdn = PageUtil.parseStringField(request.getParameter("userMdn"), "userMdn", false, 19);String userName = PageUtil.parseStringField(request.getParameter("userName"), "userName", false, 19);String userJob = PageUtil.parseStringField(request.getParameter("userJob"), "userJob", false, 199);String userCom = PageUtil.parseStringField(request.getParameter("userCom"), "userCom", false, 199);String userTel = PageUtil.parseStringField(request.getParameter("userTel"), "userTel", false, 19);String userFax = PageUtil.parseStringField(request.getParameter("userFax"), "userFax", false, 19);String userEmail = PageUtil.parseStringField(request.getParameter("userEmail"), "userEmail", false, 49);String userAdress = PageUtil.parseStringField(request.getParameter("userAdress"), "userAdress", false, 199);String userPost = PageUtil.parseStringField(request.getParameter("userPost"), "userPost", false, 199);String userMdn = PageUtil.parseStringField(request.getParameter("userMdn"), "userMdn", false, 20);String userName = PageUtil.parseStringField(request.getParameter("userName"), "userName", false, 20);String userJob = PageUtil.parseStringField(request.getParameter("userJob"), "userJob", true, 200);String userCom = PageUtil.parseStringField(request.getParameter("userCom"), "userCom", true, 200);String userTel = PageUtil.parseStringField(request.getParameter("userTel"), "userTel", true, 20);String userFax = PageUtil.parseStringField(request.getParameter("userFax"), "userFax", true, 20);String userEmail = PageUtil.parseStringField(request.getParameter("userEmail"), "userEmail", true, 50);String userAdress = PageUtil.parseStringField(request.getParameter("userAdress"), "userAdress", true, 200);String userPost = PageUtil.parseStringField(request.getParameter("userPost"), "userPost", true, 200);String userMdn = (model==null?"":""+model.getUserMdn());String userName = (model==null?"":""+model.getUserName());String userJob = (model==null?"":""+model.getUserJob());String userCom = (model==null?"":""+model.getUserCom());String userTel = (model==null?"":""+model.getUserTel());String userFax = (model==null?"":""+model.getUserFax());String userEmail = (model==null?"":""+model.getUserEmail());String userAdress = (model==null?"":""+model.getUserAdress());String userPost = (model==null?"":""+model.getUserPost());Collection coll = UserCardBean.queryAll((pageNum-1) * pageRow + 1, pageNum * pageRow);Iterator it = coll.iterator();while ( it.hasNext() ) {    Hashtable element = (Hashtable)it.next();    UserCardModel userCardModel = UserCardBean.toModel(element);    String userMdn = userCardModel.getUserMdn();    String userName = userCardModel.getUserName();    String userJob = userCardModel.getUserJob();    String userCom = userCardModel.getUserCom();    String userTel = userCardModel.getUserTel();    String userFax = userCardModel.getUserFax();    String userEmail = userCardModel.getUserEmail();    String userAdress = userCardModel.getUserAdress();    String userPost = userCardModel.getUserPost();        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userMdn+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userName+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userJob+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userCom+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userTel+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userFax+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userEmail+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userAdress+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userPost+"");*/

⌨️ 快捷键说明

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