Source:
<code>protected ResultSet executeQuery() throws SQLException { if (incrementingColumn != null && timestampColumn != null) { Timestamp startTime = new Timestamp(timestampOffset == null ? 0 : timestampOffset); <START> Timestamp endTime = new Timestamp(new Date().getTime() - timestampDelay); <END> stmt.setTimestamp(1, endTime, UTC_CALENDAR); stmt.setTimestamp(2, startTime, UTC_CALENDAR); stmt.setLong(3, (incrementingOffset == null ? -1 : incrementingOffset)); stmt.setTimestamp(4, startTime, UTC_CALENDAR); log.debug("Executing prepared statement with start time value = " + timestampOffset + " (" + startTime.toString() + ") " + " end time " + endTime.toString() + " and incrementing value = " + incrementingOffset); } else if (incrementingColumn != null) { stmt.setLong(1, (incrementingOffset == null ? -1 : incrementingOffset)); log.debug("Executing prepared statement with incrementing value = " + incrementingOffset); } else if (timestampColumn != null) { Timestamp startTime = new Timestamp(timestampOffset == null ? 0 : timestampOffset); Timestamp endTime = new Timestamp(new Date().getTime() - timestampDelay); stmt.setTimestamp(1, startTime, UTC_CALENDAR); stmt.setTimestamp(2, endTime, UTC_CALENDAR); log.debug("Executing prepared statement with timestamp value = " + timestampOffset + " (" + startTime.toString() + ") " + " end time " + endTime.toString()); } return stmt.executeQuery(); }</code><technical_language>Hmm, I thought this initial implementation. I avoided timestamps node running this susceptible time sync issues database host running connector. is pretty painful unit test for correctness. Is rewrite this do computation SQL statement</technical_language>

Target:
protected ResultSet executeQuery() throws SQLException { if (incrementingColumn != null && timestampColumn != null) { Timestamp startTime = new Timestamp(timestampOffset == null ? 0 : timestampOffset); Timestamp endTime = new Timestamp(JdbcUtils.getCurrentTimeOnDB(stmt.getConnection(), UTC_CALENDAR).getTime() - timestampDelay); stmt.setTimestamp(1, endTime, UTC_CALENDAR); stmt.setTimestamp(2, startTime, UTC_CALENDAR); stmt.setLong(3, (incrementingOffset == null ? -1 : incrementingOffset)); stmt.setTimestamp(4, startTime, UTC_CALENDAR); log.debug("Executing prepared statement with start time value = " + timestampOffset + " (" + startTime.toString() + ") " + " end time " + endTime.toString() + " and incrementing value = " + incrementingOffset); } else if (incrementingColumn != null) { stmt.setLong(1, (incrementingOffset == null ? -1 : incrementingOffset)); log.debug("Executing prepared statement with incrementing value = " + incrementingOffset); } else if (timestampColumn != null) { Timestamp startTime = new Timestamp(timestampOffset == null ? 0 : timestampOffset); Timestamp endTime = new Timestamp(JdbcUtils.getCurrentTimeOnDB(stmt.getConnection(), UTC_CALENDAR).getTime() - timestampDelay); stmt.setTimestamp(1, startTime, UTC_CALENDAR); stmt.setTimestamp(2, endTime, UTC_CALENDAR); log.debug("Executing prepared statement with timestamp value = " + timestampOffset + " (" + JdbcUtils.formatUTC(startTime) + ") " + " end time " + JdbcUtils.formatUTC(endTime)); } return stmt.executeQuery(); }