/** * 获取定量数据 * * @return LECInsuredSet */ public LECInsuredSet getData() { int tCount = 0; LECInsuredSet tLECInsuredSet = new LECInsuredSet(); LECInsuredSchema tLECInsuredSchema = null; if (null == mResultSet) { CError tError = new CError(); tError.moduleName = "LECInsuredDB"; tError.functionName = "getData"; tError.errorMessage = "数据集为空,请先准备数据集!"; this.mErrors.addOneError(tError); return null; } try { tCount = 1; tLECInsuredSchema = new LECInsuredSchema(); tLECInsuredSchema.setSchema(mResultSet, 1); tLECInsuredSet.add(tLECInsuredSchema); // 注意mResultSet.next()的作用 while (tCount++ < SysConst.FETCHCOUNT) { if (mResultSet.next()) { tLECInsuredSchema = new LECInsuredSchema(); tLECInsuredSchema.setSchema(mResultSet, 1); tLECInsuredSet.add(tLECInsuredSchema); } } } catch (Exception ex) { CError tError = new CError(); tError.moduleName = "LECInsuredDB"; 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 tLECInsuredSet; }
public LECInsuredSet executeQuery(String sql, int nStart, int nCount) { Statement stmt = null; ResultSet rs = null; LECInsuredSet aLECInsuredSet = new LECInsuredSet(); 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; } LECInsuredSchema s1 = new LECInsuredSchema(); if (!s1.setSchema(rs, i)) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LECInsuredDB"; tError.functionName = "executeQuery"; tError.errorMessage = "sql语句有误,请查看表名及字段名信息!"; this.mErrors.addOneError(tError); } aLECInsuredSet.add(s1); } try { rs.close(); } catch (Exception ex) { } try { stmt.close(); } catch (Exception ex1) { } } catch (Exception e) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LECInsuredDB"; 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 aLECInsuredSet; }
public LECInsuredSet query(int nStart, int nCount) { Statement stmt = null; ResultSet rs = null; LECInsuredSet aLECInsuredSet = new LECInsuredSet(); if (!mflag) { con = DBConnPool.getConnection(); } try { stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); SQLString sqlObj = new SQLString("LECInsured"); LECInsuredSchema aSchema = this.getSchema(); sqlObj.setSQL(5, aSchema); String sql = sqlObj.getSQL(); rs = stmt.executeQuery(sql); int i = 0; while (rs.next()) { i++; if (i < nStart) { continue; } if (i >= nStart + nCount) { break; } LECInsuredSchema s1 = new LECInsuredSchema(); s1.setSchema(rs, i); aLECInsuredSet.add(s1); } try { rs.close(); } catch (Exception ex) { } try { stmt.close(); } catch (Exception ex1) { } } catch (Exception e) { // @@错误处理 CError tError = new CError(); tError.moduleName = "LECInsuredDB"; 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 aLECInsuredSet; }