List of usage examples for java.sql ResultSet getBoolean
boolean getBoolean(String columnLabel) throws SQLException;
ResultSet
object as a boolean
in the Java programming language. From source file:com.facebook.presto.AbstractTestQueries.java
private static ResultSetMapper<Tuple> tupleMapper(final TupleInfo tupleInfo) { return new ResultSetMapper<Tuple>() { @Override/* www . j a va 2s . c o m*/ public Tuple map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException { List<TupleInfo.Type> types = tupleInfo.getTypes(); int count = resultSet.getMetaData().getColumnCount(); checkArgument(types.size() == count, "tuple info does not match result"); TupleInfo.Builder builder = tupleInfo.builder(); for (int i = 1; i <= count; i++) { TupleInfo.Type type = types.get(i - 1); switch (type) { case BOOLEAN: boolean booleanValue = resultSet.getBoolean(i); if (resultSet.wasNull()) { builder.appendNull(); } else { builder.append(booleanValue); } break; case FIXED_INT_64: long longValue = resultSet.getLong(i); if (resultSet.wasNull()) { builder.appendNull(); } else { builder.append(longValue); } break; case DOUBLE: double doubleValue = resultSet.getDouble(i); if (resultSet.wasNull()) { builder.appendNull(); } else { builder.append(doubleValue); } break; case VARIABLE_BINARY: String value = resultSet.getString(i); if (resultSet.wasNull()) { builder.appendNull(); } else { builder.append(Slices.wrappedBuffer(value.getBytes(UTF_8))); } break; default: throw new AssertionError("unhandled type: " + type); } } return builder.build(); } }; }
From source file:dk.netarkivet.harvester.datamodel.HarvestDefinitionDBDAO.java
/** * Get a sparse version of a full harvest for GUI purposes. * * @param harvestName//from w w w . j av a 2s . c o m * Name of harvest definition. * @return Sparse version of full harvest or null for none. * @throws ArgumentNotValid * on null or empty name. * @throws UnknownID * if no harvest has the given ID. * @throws IOFailure * on any other error talking to the database */ @Override public SparseFullHarvest getSparseFullHarvest(String harvestName) { ArgumentNotValid.checkNotNullOrEmpty(harvestName, "harvestName"); Connection c = HarvestDBConnection.get(); PreparedStatement s = null; try { s = c.prepareStatement("SELECT harvestdefinitions.harvest_id," + " harvestdefinitions.comments," + " harvestdefinitions.numevents," + " harvestdefinitions.isactive," + " harvestdefinitions.edition," + " fullharvests.maxobjects," + " fullharvests.maxbytes," + " fullharvests.maxjobrunningtime," + " fullharvests.previoushd, " + " harvestdefinitions.channel_id " + "FROM harvestdefinitions, fullharvests" + " WHERE harvestdefinitions.name = ?" + " AND harvestdefinitions.harvest_id " + " = fullharvests.harvest_id"); s.setString(1, harvestName); ResultSet res = s.executeQuery(); if (res.next()) { SparseFullHarvest sfh = new SparseFullHarvest(res.getLong(1), harvestName, res.getString(2), res.getInt(3), res.getBoolean(4), res.getLong(5), res.getLong(6), res.getLong(7), res.getLong(8), DBUtils.getLongMaybeNull(res, 9), DBUtils.getLongMaybeNull(res, 10)); sfh.setExtendedFieldValues(getExtendedFieldValues(sfh.getOid())); return sfh; } else { return null; } } catch (SQLException e) { throw new IOFailure("SQL error getting sparse harvest" + "\n" + ExceptionUtils.getSQLExceptionCause(e), e); } finally { DBUtils.closeStatementIfOpen(s); HarvestDBConnection.release(c); } }
From source file:com.erbjuder.logger.server.rest.util.ResultSetConverter.java
private JSONArray toJSONArray(ResultSet rs, JSONArray json) throws Exception { String temp = null;// ww w .ja v a 2 s . com try { // we will need the column names, this will save the table meta-data like column nmae. java.sql.ResultSetMetaData rsmd = rs.getMetaData(); //loop through the ResultSet while (rs.next()) { //figure out how many columns there are int numColumns = rsmd.getColumnCount(); //each row in the ResultSet will be converted to a JSON Object JSONObject obj = new JSONObject(); // loop through all the columns and place them into the JSON Object for (int i = 1; i < numColumns + 1; i++) { String column_name = rsmd.getColumnName(i); if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { obj.put(column_name, rs.getArray(column_name).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { obj.put(column_name, rs.getBigDecimal(column_name).toBigInteger().toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { obj.put(column_name, ((Boolean) rs.getBoolean(column_name)).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { obj.put(column_name, rs.getBlob(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { obj.put(column_name, ((Double) rs.getDouble(column_name)).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { obj.put(column_name, ((Float) rs.getFloat(column_name)).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { obj.put(column_name, ((Integer) rs.getInt(column_name)).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { obj.put(column_name, rs.getNString(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { // temp = rs.getString(column_name); //saving column data to temp variable // temp = ESAPI.encoder().canonicalize(temp); //decoding data to base state // temp = ESAPI.encoder().encodeForHTML(temp); //encoding to be browser safe // obj.put(column_name, temp); //putting data into JSON object // obj.put(column_name, rs.getNString(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { obj.put(column_name, ((Integer) rs.getInt(column_name)).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { obj.put(column_name, ((Integer) rs.getInt(column_name)).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { obj.put(column_name, rs.getDate(column_name).toString()); } else if (rsmd.getColumnType(i) == java.sql.Types.TIME) { obj.put(column_name, TimeStampUtils.dateTimeToString(rs.getTime(column_name))); } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { obj.put(column_name, TimeStampUtils.timeStampToString(rs.getTimestamp(column_name))); } else if (rsmd.getColumnType(i) == java.sql.Types.NUMERIC) { obj.put(column_name, rs.getBigDecimal(column_name).toString()); } else { obj.put(column_name, rs.getObject(column_name)); } } //end foreach json.add(obj); } //end while } catch (Exception e) { e.printStackTrace(); } return json; //return JSON array }
From source file:dk.netarkivet.harvester.datamodel.HarvestDefinitionDBDAO.java
/** * Get a sparse version of a partial harvest for GUI purposes. * * @param harvestName// w ww. ja v a 2 s .com * Name of harvest definition. * @return Sparse version of partial harvest or null for none. * @throws ArgumentNotValid * on null or empty name. */ @Override public SparsePartialHarvest getSparsePartialHarvest(String harvestName) { ArgumentNotValid.checkNotNullOrEmpty(harvestName, "harvestName"); Connection c = HarvestDBConnection.get(); PreparedStatement s = null; try { s = c.prepareStatement("SELECT harvestdefinitions.harvest_id," + " harvestdefinitions.comments," + " harvestdefinitions.numevents," + " harvestdefinitions.submitted," + " harvestdefinitions.isactive," + " harvestdefinitions.edition," + " schedules.name," + " partialharvests.nextdate, " + " harvestdefinitions.audience, " + " harvestdefinitions.channel_id " + "FROM harvestdefinitions, partialharvests, schedules" + " WHERE harvestdefinitions.name = ?" + " AND harvestdefinitions.harvest_id " + "= partialharvests.harvest_id" + " AND schedules.schedule_id " + "= partialharvests.schedule_id"); s.setString(1, harvestName); ResultSet res = s.executeQuery(); if (res.next()) { SparsePartialHarvest sph = new SparsePartialHarvest(res.getLong(1), harvestName, res.getString(2), res.getInt(3), new Date(res.getTimestamp(4).getTime()), res.getBoolean(5), res.getLong(6), res.getString(7), DBUtils.getDateMaybeNull(res, 8), res.getString(9), DBUtils.getLongMaybeNull(res, 10)); sph.setExtendedFieldValues(getExtendedFieldValues(sph.getOid())); return sph; } else { return null; } } catch (SQLException e) { throw new IOFailure("SQL error getting sparse harvest" + "\n" + ExceptionUtils.getSQLExceptionCause(e), e); } finally { DBUtils.closeStatementIfOpen(s); HarvestDBConnection.release(c); } }
From source file:com.sfs.whichdoctor.dao.GroupDAOImpl.java
/** * Load group./*from w w w.j av a2 s . c o m*/ * * @param rs the rs * @param loadDetails the load details * * @return the group bean * * @throws SQLException the SQL exception */ private GroupBean loadGroup(final ResultSet rs, final BuilderBean loadDetails) throws SQLException { GroupBean group = new GroupBean(); group.setId(rs.getInt("GroupId")); group.setGUID(rs.getInt("GUID")); group.setObjectType(rs.getString("ObjectType")); group.setType(rs.getString("Type")); group.setYear(rs.getInt("Year")); group.setColour(rs.getString("Colour")); group.setWeighting(rs.getInt("Weighting")); group.setPermission(rs.getString("Permission")); group.setName(rs.getString("Name")); group.setDescription(rs.getString("Description")); group.setGroupDN(rs.getString("GroupDN")); group.setItemCount(rs.getInt("ItemCount")); if (loadDetails.getBoolean("TAGS")) { try { group.setTags(this.getTagDAO().load(group.getGUID(), loadDetails.getString("USERDN"), true)); } catch (Exception e) { dataLogger.error("Error loading tags for group: " + e.getMessage()); } } group.setActive(rs.getBoolean("Active")); if (loadDetails.getBoolean("HISTORY")) { try { group.setCreatedDate(rs.getTimestamp("CreatedDate")); } catch (SQLException sqe) { dataLogger.debug("Error loading CreatedDate: " + sqe.getMessage()); } group.setCreatedBy(rs.getString("CreatedBy")); try { group.setModifiedDate(rs.getTimestamp("ModifiedDate")); } catch (SQLException sqe) { dataLogger.debug("Error loading ModifiedDate: " + sqe.getMessage()); } group.setModifiedBy(rs.getString("ModifiedBy")); } if (loadDetails.getBoolean("ITEMS")) { int referenceId = 0; try { referenceId = Integer.parseInt(loadDetails.getString("REFERENCEID")); } catch (Exception e) { dataLogger.debug("Error parsing ReferenceId: " + e.getMessage()); } try { group.setItems( this.getItemDAO().load(group.getGUID(), true, "Group", group.getObjectType(), referenceId, loadDetails.getString("ITEMS_STARTDATE"), loadDetails.getString("ITEMS_ENDDATE"))); } catch (Exception e) { dataLogger.error("Error loading items: " + e.getMessage()); } } if (StringUtils.equalsIgnoreCase(group.getType(), "Election") && loadDetails.getBoolean("VOTES")) { /* Load the votes for this election group */ try { TreeMap<Integer, VoteBean> votesCast = this.voteDAO.load(group.getGUID()); group.setVotesCast(votesCast); group.setCastVoteCount(votesCast.keySet().size()); } catch (Exception e) { dataLogger.error("Error loading votes cast: " + e.getMessage()); } try { TreeMap<Integer, Integer> eligibleVotes = this.voteDAO.loadEligible(group.getGUID()); group.setEligibleVoteCount(eligibleVotes.keySet().size()); } catch (Exception e) { dataLogger.error("Error loading eligible vote count: " + e.getMessage()); } } if (StringUtils.equalsIgnoreCase(group.getType(), "Election") && loadDetails.getBoolean("CANDIDATES")) { // * Load the candidates for this election group */ try { Collection<CandidateBean> candidates = this.candidateDAO.load(group.getGUID(), loadDetails); group.setCandidates(candidates); } catch (Exception e) { dataLogger.error("Error loading votes cast: " + e.getMessage()); } } if (loadDetails.getBoolean("IDENTITIES")) { boolean loadIdentities = false; if (StringUtils.equalsIgnoreCase(group.getObjectType(), "Organisations") || StringUtils.equalsIgnoreCase(group.getObjectType(), "Members")) { loadIdentities = true; } if (loadIdentities && group.getItems() != null) { group.setItems(loadIdentities(group.getItems())); } } if (loadDetails.getBoolean("MEMO")) { try { group.setMemo(this.getMemoDAO().load(group.getGUID(), loadDetails.getBoolean("MEMO_FULL"))); } catch (Exception e) { dataLogger.error("Error loading memos: " + e.getMessage()); } } if (loadDetails.getBoolean("CREATED")) { UserBean user = new UserBean(); user.setDN(rs.getString("CreatedBy")); user.setPreferredName(rs.getString("CreatedFirstName")); user.setLastName(rs.getString("CreatedLastName")); group.setCreatedUser(user); } if (loadDetails.getBoolean("MODIFIED")) { UserBean user = new UserBean(); user.setDN(rs.getString("ModifiedBy")); user.setPreferredName(rs.getString("ModifiedFirstName")); user.setLastName(rs.getString("ModifiedLastName")); group.setModifiedUser(user); } return group; }
From source file:com.sfs.whichdoctor.dao.SavedSearchDAOImpl.java
/** * Load the saved search.//from w ww . j a va 2 s . c o m * * @param rs the rs * @return the search bean * @throws SQLException the sQL exception */ private SearchBean loadSearch(final ResultSet rs) throws SQLException { final SearchBean search = new SearchBean(); dataLogger.debug("Loading search id: " + rs.getInt("SearchId")); search.setId(rs.getInt("SearchId")); search.setName(rs.getString("Name")); search.setDisplayOrder(rs.getInt("DisplayOrder")); search.setType(rs.getString("Type")); String strVariables = rs.getString("Variables"); Collection<Object> parameters = new ArrayList<Object>(); if (strVariables == null) { strVariables = ""; } StringTokenizer tokenizer = new StringTokenizer(strVariables, VARIABLE_DIVIDER); while (tokenizer.hasMoreTokens()) { final String variable = tokenizer.nextToken(); dataLogger.debug("Adding token: '" + variable + "'"); parameters.add(variable); } search.setSQLWhereComponents(rs.getString("SQLString"), "", parameters, search.getSearchDescription()); search.setOrderColumn(rs.getString("Order1")); search.setOrderColumn2(rs.getString("Order2")); search.setOrderColumn3(rs.getString("Order3")); try { search.setCreatedDate(rs.getDate("CreatedDate")); } catch (SQLException sqe) { dataLogger.debug("Error parsing CreatedDate: " + sqe.getMessage()); } search.setPublicSearch(rs.getBoolean("PublicSearch")); search.setFavourite(rs.getBoolean("Favourite")); search.setDescription(rs.getString("Description")); search.setDN(rs.getString("UserDn")); search.setUserName(rs.getString("UserName")); search.setSavedSearch(true); search.setOrderAscending(true); search.setRequestedPage(1); search.setLimit(DEFAULT_LIMIT); return search; }
From source file:dbProcs.Getter.java
/** * This method hashes the user submitted password and sends it to the database. * The database does the rest of the work, including Brute Force prevention. * @param userName The submitted user name to be used in authentication process * @param password The submitted password in plain text to be used in authentication * @return A string array made up of nothing or information to be consumed by the initiating authentication process. *///from ww w. j a v a2 s. c o m public static String[] authUser(String ApplicationRoot, String userName, String password) { String[] result = null; log.debug("$$$ Getter.authUser $$$"); log.debug("userName = " + userName); boolean userFound = false; boolean goOn = false; Connection conn = Database.getCoreConnection(ApplicationRoot); try { //See if user Exists CallableStatement callstmt = conn.prepareCall("call userFind(?)"); log.debug("Gathering userFind ResultSet"); callstmt.setString(1, userName); ResultSet userFind = callstmt.executeQuery(); log.debug("Opening Result Set from userFind"); try { userFind.next(); log.debug("User Found"); //User found if a row is in the database, this line will not work if the result set is empty userFound = true; } catch (Exception e) { log.debug("User did not exist"); userFound = false; } if (userFound) { //Authenticate User callstmt = conn.prepareCall("call authUser(?, ?)"); log.debug("Gathering authUser ResultSet"); callstmt.setString(1, userName); callstmt.setString(2, password); ResultSet loginAttempt = callstmt.executeQuery(); log.debug("Opening Result Set from authUser"); try { loginAttempt.next(); goOn = true; //Valid password for user submitted } catch (SQLException e) { //... Outer Catch has preference to this one for some reason... This code is never reached! // But I'll leave it here just in case. That includes the else block if goOn is false log.debug("Incorrect Credentials"); goOn = false; } if (goOn) { //ResultSet Not Empty => Credentials Correct result = new String[5]; result[0] = loginAttempt.getString(1); //Id result[1] = loginAttempt.getString(2); //userName result[2] = loginAttempt.getString(3); //role result[4] = loginAttempt.getString(6); //classId if (loginAttempt.getBoolean(5)) //Checking for temp password flag, if true, index View will prompt to change result[3] = "true"; else result[3] = "false"; if (!result[1].equals(userName)) //If somehow this functionality has been compromised to sign in as other users, this will limit the expoitability. But the method is sql injection safe, so it should be ok { log.fatal("User Name used (" + userName + ") and User Name retrieved (" + result[1] + ") were not the Same. Nulling Result"); result = null; } else { log.debug("User '" + userName + "' has logged in"); //Before finishing, check if user had a badlogin history, if so, Clear it if (loginAttempt.getInt(4) > 0) { log.debug("Clearing Bad Login History"); callstmt = conn.prepareCall("call userBadLoginReset(?)"); callstmt.setString(1, result[0]); callstmt.execute(); log.debug("userBadLoginReset executed!"); } } //User has logged in, or a Authentication Bypass was detected... You never know! Better safe than sorry return result; } } } catch (SQLException e) { log.error("Login Failure: " + e.toString()); result = null; //Lagging Response } Database.closeConnection(conn); log.debug("$$$ End authUser $$$"); return result; }
From source file:eionet.meta.dao.mysql.DataElementDAOImpl.java
/** * {@inheritDoc}//from ww w. ja va2 s . c om */ @Override public DataElement getDataElement(int id) { String sql = "select * from DATAELEM de where de.DATAELEM_ID = :id"; Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("id", id); DataElement result = getNamedParameterJdbcTemplate().queryForObject(sql, parameters, new RowMapper<DataElement>() { @Override public DataElement mapRow(ResultSet rs, int rowNum) throws SQLException { DataElement de = new DataElement(); de.setId(rs.getInt("de.DATAELEM_ID")); de.setIdentifier(rs.getString("de.IDENTIFIER")); de.setShortName(rs.getString("de.SHORT_NAME")); de.setStatus(rs.getString("de.REG_STATUS")); de.setType(rs.getString("de.TYPE")); de.setModified(new Date(rs.getLong("de.DATE"))); de.setWorkingUser(rs.getString("de.WORKING_USER")); de.setDate(rs.getString("de.DATE")); de.setAllConceptsValid(rs.getBoolean("de.ALL_CONCEPTS_LEGAL")); de.setVocabularyId(rs.getInt("de.VOCABULARY_ID")); return de; } }); return result; }
From source file:com.flexive.core.storage.genericSQL.GenericEnvironmentLoader.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s . c o m*/ */ @Override public List<FxProperty> loadProperties(Connection con, FxEnvironment environment) throws FxLoadException, FxNotFoundException { Statement stmt = null; ArrayList<FxProperty> alRet = new ArrayList<FxProperty>(50); try { final Map<Long, List<FxStructureOption>> propertyOptions = loadAllPropertyOptions(con); final Map<Long, FxString[]> mlText = Database.loadFxStrings(con, TBL_STRUCT_PROPERTIES, "DESCRIPTION", "HINT"); // 1 2 3 4 5 String sql = "SELECT ID, NAME, DEFMINMULT, DEFMAXMULT, MAYOVERRIDEMULT," + //6 7 8 9 "ACL, MAYOVERRIDEACL, DATATYPE, REFTYPE, " + //10 11 12 "ISFULLTEXTINDEXED, DEFAULT_VALUE, SYSINTERNAL, " + //13 14 "REFLIST, UNIQUEMODE FROM " + TBL_STRUCT_PROPERTIES + " ORDER BY ID ASC"; stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(sql); FxValue defaultValue; String name; long id; int minMult; int maxMult; boolean mayOverrideMult; boolean mayOverrideACL; ACL acl; FxDataType dataType; boolean fulltextIndexed; long refTypeId; long refListId; boolean systemInternal; UniqueMode uniqueMode; final XStream xStream = ConversionEngine.getXStream(); while (rs != null && rs.next()) { id = rs.getLong(1); name = rs.getString(2); minMult = rs.getInt(3); maxMult = rs.getInt(4); mayOverrideMult = rs.getBoolean(5); acl = environment.getACL(rs.getInt(6)); mayOverrideACL = rs.getBoolean(7); dataType = environment.getDataType(rs.getLong(8)); refTypeId = rs.getLong(9); if (rs.wasNull()) refTypeId = -1; fulltextIndexed = rs.getBoolean(10); String _def = rs.getString(11); defaultValue = null; if (!StringUtils.isEmpty(_def) && CacheAdmin.isEnvironmentLoaded()) { try { defaultValue = (FxValue) xStream.fromXML(_def); if (defaultValue != null && defaultValue.isEmpty()) defaultValue = null; if (defaultValue != null) { defaultValue.setXPath(name); } } catch (Exception e) { defaultValue = null; LOG.warn("Failed to decode default value for property [" + name + "]: " + e.getMessage(), e); } } systemInternal = rs.getBoolean(12); refListId = rs.getLong(13); if (rs.wasNull()) refListId = -1; uniqueMode = UniqueMode.getById(rs.getInt(14)); FxString label; FxString hint; if (mlText.containsKey(id)) { label = mlText.get(id)[0]; hint = mlText.get(id)[1]; } else { label = new FxString(""); hint = new FxString(""); } alRet.add(new FxProperty(id, name, label, hint, systemInternal, mayOverrideMult, FxMultiplicity.of(minMult, maxMult), mayOverrideACL, acl, dataType, defaultValue, fulltextIndexed, (refTypeId == -1 ? null : environment.getType(refTypeId)), (refListId == -1 ? null : environment.getSelectList(refListId)), uniqueMode, FxSharedUtils.get(propertyOptions, id, new ArrayList<FxStructureOption>(0)))); } return alRet; } catch (SQLException e) { throw new FxLoadException(LOG, e, "ex.db.sqlError", e.getMessage()); } finally { Database.closeObjects(GenericEnvironmentLoader.class, null, stmt); } }
From source file:dk.netarkivet.harvester.datamodel.HarvestDefinitionDBDAO.java
/** * Get all sparse versions of full harvests for GUI purposes. * * @return An iterable (possibly empty) of SparseFullHarvests *//*from w w w . ja v a 2 s .c o m*/ public Iterable<SparseFullHarvest> getAllSparseFullHarvestDefinitions() { Connection c = HarvestDBConnection.get(); PreparedStatement s = null; try { s = c.prepareStatement("SELECT harvestdefinitions.harvest_id," + " harvestdefinitions.name," + " harvestdefinitions.comments," + " harvestdefinitions.numevents," + " harvestdefinitions.isactive," + " harvestdefinitions.edition," + " fullharvests.maxobjects," + " fullharvests.maxbytes," + " fullharvests.maxjobrunningtime," + " fullharvests.previoushd, " + " harvestdefinitions.channel_id " + "FROM harvestdefinitions, fullharvests" + " WHERE harvestdefinitions.harvest_id " + " = fullharvests.harvest_id"); ResultSet res = s.executeQuery(); List<SparseFullHarvest> harvests = new ArrayList<SparseFullHarvest>(); while (res.next()) { SparseFullHarvest sfh = new SparseFullHarvest(res.getLong(1), res.getString(2), res.getString(3), res.getInt(4), res.getBoolean(5), res.getLong(6), res.getLong(7), res.getLong(8), res.getLong(9), DBUtils.getLongMaybeNull(res, 10), DBUtils.getLongMaybeNull(res, 11)); harvests.add(sfh); } return harvests; } catch (SQLException e) { throw new IOFailure("SQL error getting sparse harvests" + "\n" + ExceptionUtils.getSQLExceptionCause(e), e); } finally { DBUtils.closeStatementIfOpen(s); HarvestDBConnection.release(c); } }