📄 accessdao.java
字号:
+ Function.DateToString(model.getVisitTime()) + "', LEAVE_TIME = '" + Function.DateToString(model.getLeaveTime()) + "', CP_ID = " + model.getCpId() + ", CHANNEL_ID = " + model.getChannelId() + ", FEE_TYPE = " + model.getFeeType() + ", FEE_CODE = " + model.getFeeCode() + " WHERE ID = " + model.getId(); } else if (Database.dbType == DBType.MYSQL) { sql = "UPDATE WAP_ACCESS SET USER_MDN = '" + Function.writeDBEncode(model.getUserMdn()) + "', VISIT_TIME = '" + Function.DateToString(model.getVisitTime()) + "', LEAVE_TIME = '" + Function.DateToString(model.getLeaveTime()) + "', CP_ID = " + model.getCpId() + ", CHANNEL_ID = " + model.getChannelId() + ", FEE_TYPE = " + model.getFeeType() + ", FEE_CODE = " + model.getFeeCode() + " WHERE ID = " + model.getId(); } return sql; } protected static String getDeleteSQL(int id) { String sql = ""; if (Database.dbType == DBType.ORACLE) { sql = "DELETE FROM WAP_ACCESS WHERE ID = " + id; } else if (Database.dbType == DBType.SQLSERVER) { sql = "DELETE FROM WAP_ACCESS WHERE ID = " + id; } else if (Database.dbType == DBType.MYSQL) { sql = "DELETE FROM WAP_ACCESS WHERE ID = " + id; } return sql; } protected static String getDeleteSQL(int[] ids) { String sql = ""; if (Database.dbType == DBType.ORACLE) { sql = "DELETE FROM WAP_ACCESS 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_ACCESS 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_ACCESS WHERE 1 = 2"; for ( int i = 0; i < ids.length; i++ ) { sql += " OR ID = " + ids[i]; } } return sql; } protected static String getFindByPKSQL(int id) { String sql = ""; if (Database.dbType == DBType.ORACLE) { sql = "SELECT * FROM WAP_ACCESS WHERE ID = " + id; } else if (Database.dbType == DBType.SQLSERVER) { sql = "SELECT * FROM WAP_ACCESS WHERE ID = " + id; } else if (Database.dbType == DBType.MYSQL) { sql = "SELECT * FROM WAP_ACCESS WHERE ID = " + id; } return sql; } protected static boolean isValidData(AccessModel 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)) { AccessModel model=new AccessModel(); model.setId(AccessBean.getSequenceNextValue()); model.setUserMdn("abc"); model.setVisitTime(Function.getCurrTime()); model.setLeaveTime(Function.getCurrTime()); model.setCpId(1); model.setChannelId(1); model.setFeeType(1); model.setFeeCode(1); AccessModel accessModel = AccessBean.insert(model); }else if ("update".equalsIgnoreCase(action)){ AccessModel accessModel = AccessBean.findByPK(1); int id = accessModel.getId(); String userMdn = accessModel.getUserMdn(); Timestamp visitTime = accessModel.getVisitTime(); Timestamp leaveTime = accessModel.getLeaveTime(); int cpId = accessModel.getCpId(); int channelId = accessModel.getChannelId(); int feeType = accessModel.getFeeType(); int feeCode = accessModel.getFeeCode(); accessModel.setUserMdn(userMdn); accessModel.setVisitTime(visitTime); accessModel.setLeaveTime(leaveTime); accessModel.setCpId(cpId); accessModel.setChannelId(channelId); accessModel.setFeeType(feeType); accessModel.setFeeCode(feeCode); update(accessModel); }else if ("delete".equalsIgnoreCase(action)){ int[] ids = new int[3]; ids[0] = 1; ids[1] = 2; ids[2] = 3; AccessBean.delete(ids); }else if ("findByPK".equalsIgnoreCase(action)){ AccessModel accessModel = AccessBean.findByPK(1); int id = accessModel.getId(); String userMdn = accessModel.getUserMdn(); Timestamp visitTime = accessModel.getVisitTime(); Timestamp leaveTime = accessModel.getLeaveTime(); int cpId = accessModel.getCpId(); int channelId = accessModel.getChannelId(); int feeType = accessModel.getFeeType(); int feeCode = accessModel.getFeeCode(); System.out.println("id = " + id); System.out.println("userMdn = " + userMdn); System.out.println("visitTime = " + Function.getYYYYMMDDHHMISS(visitTime)); System.out.println("leaveTime = " + Function.getYYYYMMDDHHMISS(leaveTime)); System.out.println("cpId = " + cpId); System.out.println("channelId = " + channelId); System.out.println("feeType = " + feeType); System.out.println("feeCode = " + feeCode); }else if ("queryBySql".equalsIgnoreCase(action)){ Collection coll = AccessBean.queryBySql("SELECT * FROM WAP_ACCESS"); }else if ("getRowCountBySql".equalsIgnoreCase(action)){ int rowCount = AccessBean.getRowCountBySql("SELECT COUNT(*) FROM WAP_ACCESS"); System.out.println("rowCount = " + rowCount); }else if ("queryAll".equalsIgnoreCase(action)){ Collection coll = AccessBean.queryAll(); Iterator it = coll.iterator(); while ( it.hasNext() ) { Hashtable element = (Hashtable)it.next(); String id = (String)element.get("id"); String userMdn = (String)element.get("userMdn"); String visitTime = Function.getYYYYMMDDHHMISS((Timestamp)element.get("visitTime")); String leaveTime = Function.getYYYYMMDDHHMISS((Timestamp)element.get("leaveTime")); String cpId = (String)element.get("cpId"); String channelId = (String)element.get("channelId"); String feeType = (String)element.get("feeType"); String feeCode = (String)element.get("feeCode"); System.out.print("id = " + id + ",\t"); System.out.print("userMdn = " + userMdn + ",\t"); System.out.print("visitTime = " + visitTime + ",\t"); System.out.print("leaveTime = " + leaveTime + ",\t"); System.out.print("cpId = " + cpId + ",\t"); System.out.print("channelId = " + channelId + ",\t"); System.out.print("feeType = " + feeType + ",\t"); System.out.print("feeCode = " + feeCode + "\n"); } }else if ("getRowCountOfAll".equalsIgnoreCase(action)){ int rowCount = AccessBean.getRowCountOfAll(); System.out.println("rowCount = " + rowCount); }else if ("getSequenceNextValue".equalsIgnoreCase(action)){ int sequenceValue = AccessBean.getSequenceNextValue(); System.out.println("sequenceValue = " + sequenceValue); } }}/*int id = (model==null?0:model.getId());String userMdn = (model==null?"":model.getUserMdn());Timestamp visitTime = (model==null?null:model.getVisitTime());Timestamp leaveTime = (model==null?null:model.getLeaveTime());int cpId = (model==null?0:model.getCpId());int channelId = (model==null?0:model.getChannelId());int feeType = (model==null?0:model.getFeeType());int feeCode = (model==null?0:model.getFeeCode());int id = PageUtil.parseIntField(request.getParameter("id"), "id", false, 0, );String userMdn = PageUtil.parseStringField(request.getParameter("userMdn"), "userMdn", false, 19);int cpId = PageUtil.parseIntField(request.getParameter("cpId"), "cpId", false, 0, 19);int channelId = PageUtil.parseIntField(request.getParameter("channelId"), "channelId", false, 0, 19);int feeType = PageUtil.parseIntField(request.getParameter("feeType"), "feeType", false, 0, 19);int feeCode = PageUtil.parseIntField(request.getParameter("feeCode"), "feeCode", false, 0, 65535);int id = PageUtil.parseIntField(request.getParameter("id"), "id", true, 0, 999999999);String userMdn = PageUtil.parseStringField(request.getParameter("userMdn"), "userMdn", true, 20);Timestamp visitTime = PageUtil.parseDateField(request.getParameter("visitTime"), "visitTime", true);Timestamp leaveTime = PageUtil.parseDateField(request.getParameter("leaveTime"), "leaveTime", true);int cpId = PageUtil.parseIntField(request.getParameter("cpId"), "cpId", true, 0, 999999999);int channelId = PageUtil.parseIntField(request.getParameter("channelId"), "channelId", true, 0, 999999999);int feeType = PageUtil.parseIntField(request.getParameter("feeType"), "feeType", true, 0, 999999999);int feeCode = PageUtil.parseIntField(request.getParameter("feeCode"), "feeCode", true, 0, 99999);String id = (model==null?"0":""+model.getId());String userMdn = (model==null?"":""+model.getUserMdn());Timestamp visitTime = (model==null?null:model.getVisitTime());Timestamp leaveTime = (model==null?null:model.getLeaveTime());String cpId = (model==null?"0":""+model.getCpId());String channelId = (model==null?"0":""+model.getChannelId());String feeType = (model==null?"0":""+model.getFeeType());String feeCode = (model==null?"0":""+model.getFeeCode());Collection coll = AccessBean.queryAll((pageNum-1) * pageRow + 1, pageNum * pageRow);Iterator it = coll.iterator();while ( it.hasNext() ) { Hashtable element = (Hashtable)it.next(); AccessModel accessModel = AccessBean.toModel(element); int id = accessModel.getId(); String userMdn = accessModel.getUserMdn(); Timestamp visitTime = accessModel.getVisitTime(); Timestamp leaveTime = accessModel.getLeaveTime(); int cpId = accessModel.getCpId(); int channelId = accessModel.getChannelId(); int feeType = accessModel.getFeeType(); int feeCode = accessModel.getFeeCode(); excel.setCellData(new ExcelCell(ExcelUtil.INT_CELL_TYTE, currRow, currCol++), id+""); excel.setCellData(new ExcelCell(ExcelUtil.STRING_CELL_TYTE, currRow, currCol++), userMdn+""); excel.setCellData(new ExcelCell(ExcelUtil.DATE_CELL_TYTE, currRow, currCol++), visitTime); excel.setCellData(new ExcelCell(ExcelUtil.DATE_CELL_TYTE, currRow, currCol++), leaveTime); excel.setCellData(new ExcelCell(ExcelUtil.INT_CELL_TYTE, currRow, currCol++), cpId+""); excel.setCellData(new ExcelCell(ExcelUtil.INT_CELL_TYTE, currRow, currCol++), channelId+""); excel.setCellData(new ExcelCell(ExcelUtil.INT_CELL_TYTE, currRow, currCol++), feeType+""); excel.setCellData(new ExcelCell(ExcelUtil.INT_CELL_TYTE, currRow, currCol++), feeCode+"");*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -