DBUtils { public static Closeable wrapAsCloseable(final ResultSet resultSet){ return new Closeable() { @Override public void close() throws IOException { DBUtils.closeQuietly(resultSet); } }; }  static Closeable wrapAsCloseable(final ResultSet resultSet); static boolean setAutoCommit(final Connection connection, final boolean value); static void commit(final Connection connection); static boolean rollback(final Connection connection); static void closeQuietly(java.sql.ResultSet resultSet); static void closeQuietly(Statement statement); static void closeQuietly(Connection connection); static String getDBTypeForClass(final Class<?> valueType); static void setValueToPreparedStatement(int index, final PreparedStatement preparedStatement, Object value); static int setValuesToPreparedStatement(final int startIndex, final PreparedStatement preparedStatement, final Iterable values); @SuppressWarnings("unchecked") static T getValueFromResultSet(int index, final ResultSet resultSet, final Class<T> type); static String sanitizeForTableName(String input);  }
@Test public void testWrapConnectionInCloseable() throws Exception { ResultSet resultSet = mock(ResultSet.class); Closeable closeable = DBUtils.wrapAsCloseable(resultSet); closeable.close(); verify(resultSet, times(1)).close(); }