Automatic cleanup in Java API

When a connection is closed, all of the C objects it "owns" are also cleaned up. We need to add some code to the Java API, so that we can't attempt to use those C objects any longer.

This will require some smarts in the SWIG layer.