Code modified to release connection from pool when an exception is thrown.