fix copyOut close hanging bug

I encountered a bug within CopyManger when using "public long copyOut(final String sql, OutputStream to)".
If the output stream is closed and throws an IOException (e.g. its a tcp stream and other side hung up),
then the close call to the java.sql.connection hangs indefinitely. (it appeared when working against an 8.2 server)
A workaround as done here is to cancel the copy operation and then continue reading until an SQL exception stating that the operation is cancelled is thrown.
Unfortunately I couldnt get the unit test running as I am working on an old ubuntu 12.04.