@@ -84,22 +84,22 @@ private Connection acquireConnectionIfNeeded() {
8484 finally {
8585 eventHandler .jdbcConnectionAcquisitionEnd ( physicalConnection );
8686 }
87- }
88-
8987
90- try {
91- jdbcSessionOwner .afterObtainConnection ( physicalConnection );
92- }
93- catch (SQLException e ) {
9488 try {
95- // given the session a chance to set the schema
96- jdbcSessionOwner .getJdbcConnectionAccess ().releaseConnection ( physicalConnection );
89+ jdbcSessionOwner .afterObtainConnection ( physicalConnection );
9790 }
98- catch (SQLException re ) {
99- e .addSuppressed ( re );
91+ catch (SQLException e ) {
92+ try {
93+ // given the session a chance to set the schema
94+ jdbcSessionOwner .getJdbcConnectionAccess ().releaseConnection ( physicalConnection );
95+ }
96+ catch (SQLException re ) {
97+ e .addSuppressed ( re );
98+ }
99+ throw jdbcSessionOwner .getSqlExceptionHelper ()
100+ .convert ( e , "Error after acquiring JDBC Connection" );
100101 }
101- throw jdbcSessionOwner .getSqlExceptionHelper ()
102- .convert ( e , "Error after acquiring JDBC Connection" );
102+
103103 }
104104
105105 return physicalConnection ;
@@ -181,16 +181,16 @@ public void manualReconnect(Connection suppliedConnection) {
181181 }
182182
183183 private void releaseConnection () {
184- try {
185- // give the session a chance to change the schema back to null
186- jdbcSessionOwner .beforeReleaseConnection ( physicalConnection );
187- }
188- catch (SQLException e ) {
189- log .warn ( "Error before releasing JDBC connection" , e );
190- }
191-
192184 final Connection localVariableConnection = physicalConnection ;
193185 if ( localVariableConnection != null ) {
186+ try {
187+ // give the session a chance to change the schema back to null
188+ jdbcSessionOwner .beforeReleaseConnection ( physicalConnection );
189+ }
190+ catch (SQLException e ) {
191+ log .warn ( "Error before releasing JDBC connection" , e );
192+ }
193+
194194 final JdbcEventHandler eventHandler = jdbcSessionOwner .getJdbcSessionContext ().getEventHandler ();
195195 // We need to set the connection to null before we release resources,
196196 // in order to prevent recursion into this method.
0 commit comments