Reimplement RichConnection#withPreparedStatement() using With.

Change-Id: I7a801a0394a4a2538b90eba65984a51e6b73407e
Reimplement Migration#execute() using With.

Change-Id: I298a9563697498e56133674996833a67ba341f18
Merge branch 'reimplement-methods-using-with'

Change-Id: I7199b6b5f37b981194714819aa416f144bc4128d
Add With.jarFile() and use it.

Change-Id: I151b7a862063676c7a1f414f835a94c57b8b30cf
Merge branch 'add-with-jarfile'

Change-Id: I538366996eb4206d550c9fb28c9eee239fb494d5
Assert With.*() properly handles closure and close() throwing.

If the closure passed to With.{connection,statement,resultSet} throws
and if Connection#close(), Statement#close() or ResultSet#close(),
respectively, also throws, then the exception from the closure should
be the one that is thrown to the caller, not the one from close().

Change-Id: I854a8bc5fda429d23e3bc57a044e7527eb59fe04
With.*(): use longer argument names for resource arguments.

Change-Id: Ib2e2b5cd140449f54750450dcfd4f224e064533b
Refactor With.*() common logic into new With.resource().

Change-Id: I3e9418b0a5cebbf0ef47b7bae027eb20989b195d
With.resource(): closer function can throw if body doesn't throw.

This change inspired by Java 7's try-with-resources [1] where an
exception thrown by closer is not suppressed if the body did not throw
an exception.  This ensures that the caller always is thrown an
exception if one occurred.

[1] http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.20.3

Change-Id: I6a0f3d0b5d306424f9889973902743d5d5ab9948
ConnectionBuilder now uses With.connection() to close connection.

Instead of having ConnectionBuilder#withConnection() implement its own
connection cleanup code have it use With.connection() instead.  The
original code incorrectly suppressed any exceptions thrown from
Connection#close() if the closure passed to withConnection() didn't
throw an exception.

Change-Id: I2730ea00211a3894174589496cffed8563f312a7
Simplify and fix ConnectionBuilder#withConnection() edge-cases.

In the previous implementation, if CommitUponReturnOrException or
CommitUponReturnOrRollbackUponException was used, then if the commit
threw an exception, it would be treated the same as the body throwing
an exception.  Hence CommitUponReturnOrException would try a second
commit and CommitUponReturnOrRollbackUponException would try to
rollback the transaction; the later being acceptable behavior.

The new implementation distinguishes between the body throwing an
exception and the following commit or rollback throwing an exception.

Change-Id: I617bb31a94373205088505b6641aa25c8f1e4431
Rename With.connection() to With.autoClosingConnection().

This makes space for other methods that operate on the connection
after the body has completed, such as restoring its auto-commit state.

Change-Id: I51fa1d040043b26d440c6d771279f522c8282f70
Rename With.statement() to With.autoClosingStatement().

Change-Id: Iac8f7428497713b24d14988c1d8944d2a49c2886
Rename With.resultSet() to With.autoClosingResultSet().

Change-Id: Ic7e9e074f112c92485fcba9d195e72924c253d8b
Refactor ConnectionBuilder's auto-{commit,rollback} into With.

Change-Id: Ia0385b3d025b0993d47ce48e1be672feebc5878d
Add With.autoCommittingConnection() and use it.

Change-Id: Ibc921a4c754c08a11a7ac9a02d99c601b5fcdab3
Reimplement Migration#withPreparedStatement() using With.

Now that Migration#withPreparedStatement() uses With, there is only
one finally block in the entire project, which ensures that all
resources are properly closed and that any exceptions thrown by closer
functions are properly unsuppressed if the body does not throw an
exception.

Change-Id: I89efbfbbba0f4ac8515b6c2362e1702482a2cc9c
With.autoClosingConnection() now parameterizes Connection arg.

Following With.autoClosingStatement() which is parameterized with a
Statement subclass, do the same with With.autoClosingConnection().
This allows functions taking a java.sql.Connection subclass as the
function parameter to be passed to With.autoClosingConnection();
previously such functions would be rejected during compilation.

Change-Id: Id9b305d152c8b300d505a61d2eac5368d05c6d93
With.autoClosingStatement() documentation improvement.

Change-Id: Ia2eb989aa21d88e43c51f7f6f7b2bb0790a2dbd9
With.autoClosingResultSet() now parameterizes ResultSet arg.

Following With.autoClosingStatement() which is parameterized with a
Statement subclass, do the same with With.autoClosingResultSet().
This allows functions taking a java.sql.ResultSet subclass as the
function parameter to be passed to With.autoClosingResultSet().

Change-Id: I6a84d06cfeaf9ffc506eda1ac501461db4ba43f9