/** * 获取定量数据 * * @return LEDEPolicyMailInfoSet */ public LEDEPolicyMailInfoSet getData() { int tCount = 0; LEDEPolicyMailInfoSet tLEDEPolicyMailInfoSet = new LEDEPolicyMailInfoSet(); LEDEPolicyMailInfoSchema tLEDEPolicyMailInfoSchema = null; if (null == mResultSet) { CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "getData"; tError.errorMessage = "数据集为空,请先准备数据集!"; this.mErrors.addOneError(tError); return null; } try { tCount = 1; tLEDEPolicyMailInfoSchema = new LEDEPolicyMailInfoSchema(); tLEDEPolicyMailInfoSchema.setSchema(mResultSet, 1); tLEDEPolicyMailInfoSet.add(tLEDEPolicyMailInfoSchema); // 注意mResultSet.next()的作用 while (tCount++ < SysConst.FETCHCOUNT) { if (mResultSet.next()) { tLEDEPolicyMailInfoSchema = new LEDEPolicyMailInfoSchema(); tLEDEPolicyMailInfoSchema.setSchema(mResultSet, 1); tLEDEPolicyMailInfoSet.add(tLEDEPolicyMailInfoSchema); } } } catch (Exception ex) { CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "getData"; tError.errorMessage = ex.toString(); this.mErrors.addOneError(tError); try { mResultSet.close(); mResultSet = null; } catch (Exception ex2) { } try { mStatement.close(); mStatement = null; } catch (Exception ex3) { } if (!mflag) { try { con.close(); } catch (Exception et) { } } return null; } return tLEDEPolicyMailInfoSet; }
/** * 获取数据集 * * @return boolean */ public boolean hasMoreData() { boolean flag = true; if (null == mResultSet) { CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "hasMoreData"; tError.errorMessage = "数据集为空,请先准备数据集!"; this.mErrors.addOneError(tError); return false; } try { flag = mResultSet.next(); } catch (Exception ex) { CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "hasMoreData"; tError.errorMessage = ex.toString(); this.mErrors.addOneError(tError); try { mResultSet.close(); mResultSet = null; } catch (Exception ex2) { } try { mStatement.close(); mStatement = null; } catch (Exception ex3) { } if (!mflag) { try { con.close(); } catch (Exception et) { } } return false; } return flag; }
public LEDEPolicyMailInfoSet query() { Statement stmt = null; ResultSet rs = null; LEDEPolicyMailInfoSet aLEDEPolicyMailInfoSet = new LEDEPolicyMailInfoSet(); if (!mflag) { con = DBConnPool.getConnection(); } try { stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); SQLString sqlObj = new SQLString("LEDEPolicyMailInfo"); LEDEPolicyMailInfoSchema aSchema = this.getSchema(); sqlObj.setSQL(5, aSchema); String sql = sqlObj.getSQL(); rs = stmt.executeQuery(sql); int i = 0; while (rs.next()) { i++; LEDEPolicyMailInfoSchema s1 = new LEDEPolicyMailInfoSchema(); s1.setSchema(rs, i); aLEDEPolicyMailInfoSet.add(s1); } try { rs.close(); } catch (Exception ex) { } try { stmt.close(); } catch (Exception ex1) { } } catch (Exception e) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "query"; tError.errorMessage = e.toString(); this.mErrors.addOneError(tError); try { rs.close(); } catch (Exception ex2) { } try { stmt.close(); } catch (Exception ex3) { } if (!mflag) { try { con.close(); } catch (Exception et) { } } } if (!mflag) { try { con.close(); } catch (Exception e) { } } return aLEDEPolicyMailInfoSet; }
public LEDEPolicyMailInfoSet executeQuery(String sql, int nStart, int nCount) { Statement stmt = null; ResultSet rs = null; LEDEPolicyMailInfoSet aLEDEPolicyMailInfoSet = new LEDEPolicyMailInfoSet(); if (!mflag) { con = DBConnPool.getConnection(); } try { stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery(StrTool.GBKToUnicode(sql)); int i = 0; while (rs.next()) { i++; if (i < nStart) { continue; } if (i >= nStart + nCount) { break; } LEDEPolicyMailInfoSchema s1 = new LEDEPolicyMailInfoSchema(); if (!s1.setSchema(rs, i)) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "executeQuery"; tError.errorMessage = "sql语句有误,请查看表名及字段名信息!"; this.mErrors.addOneError(tError); } aLEDEPolicyMailInfoSet.add(s1); } try { rs.close(); } catch (Exception ex) { } try { stmt.close(); } catch (Exception ex1) { } } catch (Exception e) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "executeQuery"; tError.errorMessage = e.toString(); this.mErrors.addOneError(tError); try { rs.close(); } catch (Exception ex2) { } try { stmt.close(); } catch (Exception ex3) { } if (!mflag) { try { con.close(); } catch (Exception et) { } } } if (!mflag) { try { con.close(); } catch (Exception e) { } } return aLEDEPolicyMailInfoSet; }
public boolean getInfo() { PreparedStatement pstmt = null; ResultSet rs = null; if (!mflag) { con = DBConnPool.getConnection(); } try { pstmt = con.prepareStatement( "SELECT * FROM LEDEPolicyMailInfo WHERE FreeNo = ?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); if (this.getFreeNo() == null || this.getFreeNo().equals("null")) { pstmt.setNull(1, 12); } else { pstmt.setString(1, this.getFreeNo()); } rs = pstmt.executeQuery(); int i = 0; while (rs.next()) { i++; if (!this.setSchema(rs, i)) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "getInfo"; tError.errorMessage = "取数失败!"; this.mErrors.addOneError(tError); try { rs.close(); } catch (Exception ex) { } try { pstmt.close(); } catch (Exception ex1) { } if (!mflag) { try { con.close(); } catch (Exception et) { } } return false; } break; } try { rs.close(); } catch (Exception ex2) { } try { pstmt.close(); } catch (Exception ex3) { } if (i == 0) { if (!mflag) { try { con.close(); } catch (Exception et) { } } return false; } } catch (Exception e) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LEDEPolicyMailInfoDB"; tError.functionName = "getInfo"; tError.errorMessage = e.toString(); this.mErrors.addOneError(tError); try { rs.close(); } catch (Exception ex) { } try { pstmt.close(); } catch (Exception ex1) { } if (!mflag) { try { con.close(); } catch (Exception et) { } } return false; } // 断开数据库连接 if (!mflag) { try { con.close(); } catch (Exception e) { } } return true; }