// return the records count number according sql public long getRecordsCountFromSql(String sql) throws FrameworkDAOException { // Initialize values ResultSet ret = null; Statement stmt = null; Connection connection = null; int count = 0; try { // String sSQL = sql; connection = ((DatabaseQuerier) getConnection()).getSafeConnection(); stmt = connection.createStatement(); ret = stmt.executeQuery(sql); while (ret.next()) { count++; } } catch (Exception exc) { throw new FrameworkDAOException( "S_Framework_Entry_UIDAO:getRecordsCountFromSql - " + exc, exc); } finally { String errorMsg = "Inside S_Framework_Entry_UIDAO:getRecordsCountFromSql()"; try { if (ret != null) { ret.close(); ret = null; } } catch (Exception e) { FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e); } try { if (stmt != null) { stmt.close(); stmt = null; } } catch (Exception e) { FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e); } try { if (connection != null) { connection.close(); connection = null; } } catch (Exception e) { FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e); } } return count; }
/** * @return * @throws FrameworkDAOException */ public long getMaxOIDForS_Framework_Entry_UIValueObjects() throws FrameworkDAOException { // Initialize values ResultSet ret = null; Statement stmt = null; Connection connection = null; long count = 0; String sGetMaxOIDSql = "select max(testid) from test"; try { connection = ((DatabaseQuerier) getConnection()).getSafeConnection(); stmt = connection.createStatement(); ret = stmt.executeQuery(sGetMaxOIDSql); while (ret.next()) { count = ret.getLong(1); } } catch (Exception exc) { throw new FrameworkDAOException( "S_Framework_Entry_UIDAO:getMaxOIDForS_Framework_Entry_UIValueObjects - " + exc, exc); } finally { String errorMsg = "Inside S_Framework_Entry_UIDAO:getMaxOIDForS_Framework_Entry_UIValueObjects()"; try { if (ret != null) { ret.close(); ret = null; } } catch (Exception e) { FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e); } try { if (stmt != null) { stmt.close(); stmt = null; } } catch (Exception e) { FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e); } try { if (connection != null) { connection.close(); connection = null; } } catch (Exception e) { FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e); } } return count; }
/** * Creates an associated valueObject and populates it with data from the ResultSet. * * @param ResultSet rs * @return IFrameworkValueObject */ protected IFrameworkValueObject createValueObject(ResultSet rs) { IS_Framework_Entry_UIValueObject valueObject = null; try { // use the ResultSet to get data related to this class valueObject = getS_Framework_Entry_UIValueObject(); if (valueObject == null) // create one { valueObject = new S_Framework_Entry_UIValueObject(); } // ********************************************************** // Step #1 // assign the S_Framework_Entry_UI primary key using the provided ResultSet // ********************************************************** // v 2.3 - in order to effectively handle inheritance, now assign the pk fields directly // to the valueobject as attribute(s) // S_Framework_Entry_UIPrimaryKey pk = new S_Framework_Entry_UIPrimaryKey( // assignSafeLong( rs.getString( 1 ) ) ); // valueObject.setFrameworkPrimaryKey( pk ); // ********************************************************** // Step #2 // assign the remaining attributes to the value object // ********************************************************** // AIB Generated Section - Do Not Modify Within valueObject.setEntryUIID(rs.getString("entryUIID")); valueObject.setSystemid(rs.getString("systemid")); valueObject.setName(rs.getString("name")); valueObject.setDetailName(rs.getString("detailName")); valueObject.setHelp(rs.getString("help")); valueObject.setIsWorkFlow(rs.getString("isWorkFlow")); valueObject.setInWorkFlow(rs.getString("inWorkFlow")); valueObject.setExt1(rs.getString("ext1")); valueObject.setExt2(rs.getString("ext2")); valueObject.setExt3(rs.getString("ext3")); valueObject.setExt4(rs.getString("ext4")); valueObject.setExt5(rs.getString("ext5")); valueObject.setExt6(rs.getString("ext6")); valueObject.setExt7(rs.getString("ext7")); valueObject.setExt8(rs.getString("ext8")); valueObject.setExt9(rs.getString("ext9")); valueObject.setExt10(rs.getString("ext10")); valueObject.setExt11(rs.getString("ext11")); valueObject.setExt12(rs.getString("ext12")); valueObject.setExt13(rs.getString("ext13")); valueObject.setExt14(rs.getString("ext14")); valueObject.setExt15(rs.getString("ext15")); valueObject.setExt16(rs.getString("ext16")); valueObject.setExt17(rs.getString("ext17")); valueObject.setExt18(rs.getString("ext18")); valueObject.setExt19(rs.getString("ext19")); valueObject.setExt20(rs.getString("ext20")); valueObject.setCreator(rs.getString("creator")); valueObject.setCreatedTime(rs.getTimestamp("createdTime")); valueObject.setLastUpdatedBy(rs.getString("lastUpdatedBy")); valueObject.setLastUpdatedTime(rs.getTimestamp("lastUpdatedTime")); valueObject.setRefreshTime(rs.getTimestamp("refreshTime")); valueObject.setUploadFlag(rs.getString("uploadFlag")); valueObject.setDownloadFlag(rs.getString("downloadFlag")); valueObject.setDeleteFlag(rs.getString("deleteFlag")); valueObject.setVersion(rs.getString("version")); // ~AIB Generated // apply the valueObject so it may be referred to by the base class // in its implementation of this method setS_Framework_Entry_UIValueObject(valueObject); // if there is a base class, let it get its attributes from the Resultset super.createValueObject(rs); } catch (Exception exc) { printMessage("S_Framework_Entry_UIDAO:createValueObject()-" + exc); } return (valueObject); }