/** * Updates the given entry. If no error occurs, the number of updated rows is returned. * * @param entry the entry to updated * @return the number of updated rows * @throws DataAccessException if an error occurs */ public int updateRegistryEntry(RegistryEntry entry) throws DataAccessException { Connection con = null; PreparedStatement ps = null; int rowsUpdated = 0; try { con = getConnection(); ps = con.prepareStatement(queryDesc.getUpdateEntryQuery()); ps.setLong(1, entry.getPeriod()); ps.setString(2, entry.getActive() ? "Y" : "N"); ps.setString(3, entry.getTaskBeanFile()); ps.setLong(4, entry.getLastUpdate()); ps.setString(5, RegistryEntryStatus.UPDATED); short numberOfExtraProperties = queryDesc.getNumberOfExtraColumns(); String[] extraProperties = queryDesc.getExtraProperties(); if (numberOfExtraProperties > 0) { short j = 0; for (; j < numberOfExtraProperties; j++) { Object value = null; if (entry.hasProperty(extraProperties[j])) { value = entry.getProperty(extraProperties[j]); } ps.setObject(6 + j, value); } ps.setLong(6 + j, entry.getId()); } else { ps.setLong(6, entry.getId()); } rowsUpdated = ps.executeUpdate(); } catch (Exception e) { throw new DataAccessException("Error updating registry entry '" + entry.getId() + "'", e); } finally { DBTools.close(con, ps, null); } return rowsUpdated; }