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

📄 booktermdao.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
          + model.getRegType() + ")";    }    return sql;  }  protected static String getUpdateSQL(BookTermModel model) {    String sql = "";    if (Database.dbType == DBType.ORACLE) {      sql = "UPDATE WAP_BOOK_TERM SET TERM_NAME = '"          + Function.writeDBEncode(model.getTermName()) + "', USER_MDN = '"          + Function.writeDBEncode(model.getUserMdn()) + "', TERM_ATTR = '"          + Function.writeDBEncode(model.getTermAttr()) + "', REG_DATE = TO_DATE('"          + Function.DateToString(model.getRegDate()) + "', 'YYYY-MM-DD HH24:MI:SS'), REG_TYPE = "          + model.getRegType() + " WHERE ID = " + model.getId();    } else if (Database.dbType == DBType.SQLSERVER) {      sql = "UPDATE WAP_BOOK_TERM SET TERM_NAME = '"          + Function.writeDBEncode(model.getTermName()) + "', USER_MDN = '"          + Function.writeDBEncode(model.getUserMdn()) + "', TERM_ATTR = '"          + Function.writeDBEncode(model.getTermAttr()) + "', REG_DATE = '"          + Function.DateToString(model.getRegDate()) + "', REG_TYPE = "          + model.getRegType() + " WHERE ID = " + model.getId();    } else if (Database.dbType == DBType.MYSQL) {      sql = "UPDATE WAP_BOOK_TERM SET TERM_NAME = '"          + Function.writeDBEncode(model.getTermName()) + "', USER_MDN = '"          + Function.writeDBEncode(model.getUserMdn()) + "', TERM_ATTR = '"          + Function.writeDBEncode(model.getTermAttr()) + "', REG_DATE = '"          + Function.DateToString(model.getRegDate()) + "', REG_TYPE = "          + model.getRegType() + " WHERE ID = " + model.getId();    }    return sql;  }  protected static String getDeleteSQL(long id) {    String sql = "";    if (Database.dbType == DBType.ORACLE) {      sql = "DELETE FROM WAP_BOOK_TERM WHERE ID = " + id;    } else if (Database.dbType == DBType.SQLSERVER) {      sql = "DELETE FROM WAP_BOOK_TERM WHERE ID = " + id;    } else if (Database.dbType == DBType.MYSQL) {      sql = "DELETE FROM WAP_BOOK_TERM WHERE ID = " + id;    }    return sql;  }  protected static String getDeleteSQL(long[] ids) {    String sql = "";    if (Database.dbType == DBType.ORACLE) {      sql = "DELETE FROM WAP_BOOK_TERM WHERE 1 = 2";      for ( int i = 0; i < ids.length; i++ ) {        sql += " OR ID = " + ids[i];      }    } else if (Database.dbType == DBType.SQLSERVER) {      sql = "DELETE FROM WAP_BOOK_TERM WHERE 1 = 2";      for ( int i = 0; i < ids.length; i++ ) {        sql += " OR ID = " + ids[i];      }    } else if (Database.dbType == DBType.MYSQL) {      sql = "DELETE FROM WAP_BOOK_TERM WHERE 1 = 2";      for ( int i = 0; i < ids.length; i++ ) {        sql += " OR ID = " + ids[i];      }    }    return sql;  }  protected static String getFindByPKSQL(long id) {    String sql = "";    if (Database.dbType == DBType.ORACLE) {      sql = "SELECT * FROM WAP_BOOK_TERM WHERE ID = " + id;    } else if (Database.dbType == DBType.SQLSERVER) {      sql = "SELECT * FROM WAP_BOOK_TERM WHERE ID = " + id;    } else if (Database.dbType == DBType.MYSQL) {      sql = "SELECT * FROM WAP_BOOK_TERM WHERE ID = " + id;    }    return sql;  }  protected static boolean isValidData(BookTermModel 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)) {      BookTermModel model=new BookTermModel();      model.setId(999999999999999999L);      model.setTermName("abc");      model.setUserMdn("abc");      model.setTermAttr("abc");      model.setRegDate(Function.getCurrTime());      model.setRegType(999999999999999999L);      BookTermModel bookTermModel = BookTermBean.insert(model);    }else if ("update".equalsIgnoreCase(action)){      BookTermModel bookTermModel = BookTermBean.findByPK(1);      long id = bookTermModel.getId();      String termName = bookTermModel.getTermName();      String userMdn = bookTermModel.getUserMdn();      String termAttr = bookTermModel.getTermAttr();      Timestamp regDate = bookTermModel.getRegDate();      long regType = bookTermModel.getRegType();      bookTermModel.setTermName(termName);      bookTermModel.setUserMdn(userMdn);      bookTermModel.setTermAttr(termAttr);      bookTermModel.setRegDate(regDate);      bookTermModel.setRegType(regType);      update(bookTermModel);    }else if ("delete".equalsIgnoreCase(action)){      long[] ids = new long[3];      ids[0] = 1;      ids[1] = 2;      ids[2] = 3;      BookTermBean.delete(ids);    }else if ("findByPK".equalsIgnoreCase(action)){      BookTermModel bookTermModel = BookTermBean.findByPK(1);      long id = bookTermModel.getId();      String termName = bookTermModel.getTermName();      String userMdn = bookTermModel.getUserMdn();      String termAttr = bookTermModel.getTermAttr();      Timestamp regDate = bookTermModel.getRegDate();      long regType = bookTermModel.getRegType();      System.out.println("id = " + id);      System.out.println("termName = " + termName);      System.out.println("userMdn = " + userMdn);      System.out.println("termAttr = " + termAttr);      System.out.println("regDate = " + Function.getYYYYMMDDHHMISS(regDate));      System.out.println("regType = " + regType);    }else if ("queryBySql".equalsIgnoreCase(action)){      Collection coll = BookTermBean.queryBySql("SELECT * FROM WAP_BOOK_TERM");    }else if ("getRowCountBySql".equalsIgnoreCase(action)){      int rowCount = BookTermBean.getRowCountBySql("SELECT COUNT(*) FROM WAP_BOOK_TERM");      System.out.println("rowCount = " + rowCount);    }else if ("queryAll".equalsIgnoreCase(action)){      Collection coll = BookTermBean.queryAll();      Iterator it = coll.iterator();      while ( it.hasNext() ) {        Hashtable element = (Hashtable)it.next();        String id = (String)element.get("id");        String termName = (String)element.get("termName");        String userMdn = (String)element.get("userMdn");        String termAttr = (String)element.get("termAttr");        String regDate = Function.getYYYYMMDDHHMISS((Timestamp)element.get("regDate"));        String regType = (String)element.get("regType");        System.out.print("id = " + id + ",\t");        System.out.print("termName = " + termName + ",\t");        System.out.print("userMdn = " + userMdn + ",\t");        System.out.print("termAttr = " + termAttr + ",\t");        System.out.print("regDate = " + regDate + ",\t");        System.out.print("regType = " + regType + "\n");      }    }else if ("getRowCountOfAll".equalsIgnoreCase(action)){      int rowCount = BookTermBean.getRowCountOfAll();      System.out.println("rowCount = " + rowCount);    }else if ("getSequenceNextValue".equalsIgnoreCase(action)){      int sequenceValue = BookTermBean.getSequenceNextValue();      System.out.println("sequenceValue = " + sequenceValue);    }  }}/*long id = (model==null?0:model.getId());String termName = (model==null?"":model.getTermName());String userMdn = (model==null?"":model.getUserMdn());String termAttr = (model==null?"":model.getTermAttr());Timestamp regDate = (model==null?null:model.getRegDate());long regType = (model==null?0:model.getRegType());long id = PageUtil.parseLongField(request.getParameter("id"), "id", false, 0, );String termName = PageUtil.parseStringField(request.getParameter("termName"), "termName", false, 19);String userMdn = PageUtil.parseStringField(request.getParameter("userMdn"), "userMdn", false, 19);String termAttr = PageUtil.parseStringField(request.getParameter("termAttr"), "termAttr", false, 19);long regType = PageUtil.parseLongField(request.getParameter("regType"), "regType", false, 0, 19);long id = PageUtil.parseLongField(request.getParameter("id"), "id", false, 0, 0);String termName = PageUtil.parseStringField(request.getParameter("termName"), "termName", false, 20);String userMdn = PageUtil.parseStringField(request.getParameter("userMdn"), "userMdn", false, 20);String termAttr = PageUtil.parseStringField(request.getParameter("termAttr"), "termAttr", true, 20);Timestamp regDate = PageUtil.parseDateField(request.getParameter("regDate"), "regDate", true);long regType = PageUtil.parseLongField(request.getParameter("regType"), "regType", true, 0, 0);String id = (model==null?"0":""+model.getId());String termName = (model==null?"":""+model.getTermName());String userMdn = (model==null?"":""+model.getUserMdn());String termAttr = (model==null?"":""+model.getTermAttr());Timestamp regDate = (model==null?null:model.getRegDate());String regType = (model==null?"0":""+model.getRegType());Collection coll = BookTermBean.queryAll((pageNum-1) * pageRow + 1, pageNum * pageRow);Iterator it = coll.iterator();while ( it.hasNext() ) {    Hashtable element = (Hashtable)it.next();    BookTermModel bookTermModel = BookTermBean.toModel(element);    long id = bookTermModel.getId();    String termName = bookTermModel.getTermName();    String userMdn = bookTermModel.getUserMdn();    String termAttr = bookTermModel.getTermAttr();    Timestamp regDate = bookTermModel.getRegDate();    long regType = bookTermModel.getRegType();        excel.setCellData(new ExcelCell(ExcelUtil.INT_CELL_TYTE,    currRow, currCol++), id+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), termName+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userMdn+"");        excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), termAttr+"");        excel.setCellData(new ExcelCell(ExcelUtil.DATE_CELL_TYTE,   currRow, currCol++), regDate);        excel.setCellData(new ExcelCell(ExcelUtil.INT_CELL_TYTE,    currRow, currCol++), regType+"");*/

⌨️ 快捷键说明

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