|
4 | 4 | */ |
5 | 5 | package org.hibernate.engine.jdbc.internal; |
6 | 6 |
|
7 | | -import java.io.IOException; |
8 | | -import java.io.ObjectInputStream; |
9 | | -import java.io.ObjectOutputStream; |
10 | | -import java.sql.Connection; |
11 | | -import java.sql.ResultSet; |
12 | | -import java.sql.SQLException; |
13 | | -import java.sql.Statement; |
14 | | -import java.util.function.Supplier; |
15 | | - |
16 | 7 | import org.hibernate.ConnectionReleaseMode; |
17 | 8 | import org.hibernate.HibernateException; |
18 | 9 | import org.hibernate.TransactionException; |
19 | 10 | import org.hibernate.engine.jdbc.batch.JdbcBatchLogging; |
20 | 11 | import org.hibernate.engine.jdbc.batch.spi.Batch; |
21 | 12 | import org.hibernate.engine.jdbc.batch.spi.BatchKey; |
22 | 13 | import org.hibernate.engine.jdbc.mutation.group.PreparedStatementGroup; |
23 | | -import org.hibernate.engine.jdbc.spi.InvalidatableWrapper; |
24 | 14 | import org.hibernate.engine.jdbc.spi.JdbcCoordinator; |
25 | 15 | import org.hibernate.engine.jdbc.spi.JdbcServices; |
26 | 16 | import org.hibernate.engine.jdbc.spi.JdbcWrapper; |
|
40 | 30 | import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor; |
41 | 31 | import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransaction; |
42 | 32 |
|
| 33 | +import java.io.IOException; |
| 34 | +import java.io.ObjectInputStream; |
| 35 | +import java.io.ObjectOutputStream; |
| 36 | +import java.sql.Connection; |
| 37 | +import java.sql.SQLException; |
| 38 | +import java.sql.Statement; |
| 39 | +import java.util.function.Supplier; |
| 40 | + |
43 | 41 | import static org.hibernate.ConnectionReleaseMode.AFTER_STATEMENT; |
44 | 42 |
|
45 | 43 | /** |
@@ -357,71 +355,6 @@ public void disableReleases() { |
357 | 355 | releasesEnabled = false; |
358 | 356 | } |
359 | 357 |
|
360 | | - protected void close(Statement statement) { |
361 | | - LOG.tracev( "Closing prepared statement [{0}]", statement ); |
362 | | - |
363 | | - // Important for Statement caching -- some DBs (especially Sybase) log warnings on every Statement under |
364 | | - // certain situations. |
365 | | - sqlExceptionHelper().logAndClearWarnings( statement ); |
366 | | - |
367 | | - if ( statement instanceof InvalidatableWrapper ) { |
368 | | - @SuppressWarnings("unchecked") |
369 | | - final InvalidatableWrapper<Statement> wrapper = (InvalidatableWrapper<Statement>) statement; |
370 | | - close( wrapper.getWrappedObject() ); |
371 | | - wrapper.invalidate(); |
372 | | - } |
373 | | - else { |
374 | | - try { |
375 | | - // if we are unable to "clean" the prepared statement, |
376 | | - // we do not close it |
377 | | - try { |
378 | | - if ( statement.getMaxRows() != 0 ) { |
379 | | - statement.setMaxRows( 0 ); |
380 | | - } |
381 | | - if ( statement.getQueryTimeout() != 0 ) { |
382 | | - statement.setQueryTimeout( 0 ); |
383 | | - } |
384 | | - } |
385 | | - catch( SQLException sqle ) { |
386 | | - // there was a problem "cleaning" the prepared statement |
387 | | - if ( LOG.isDebugEnabled() ) { |
388 | | - LOG.debugf( "Exception clearing maxRows/queryTimeout [%s]", sqle.getMessage() ); |
389 | | - } |
390 | | - // EARLY EXIT!!! |
391 | | - return; |
392 | | - } |
393 | | - statement.close(); |
394 | | - if ( lastQuery == statement ) { |
395 | | - lastQuery = null; |
396 | | - } |
397 | | - } |
398 | | - catch ( Exception e ) { |
399 | | - LOG.debugf( "Unable to release JDBC statement [%s]", e.getMessage() ); |
400 | | - } |
401 | | - } |
402 | | - } |
403 | | - |
404 | | - |
405 | | - protected void close(ResultSet resultSet) { |
406 | | - LOG.tracev( "Closing result set [{0}]", resultSet ); |
407 | | - |
408 | | - if ( resultSet instanceof InvalidatableWrapper ) { |
409 | | - @SuppressWarnings("unchecked") |
410 | | - final InvalidatableWrapper<ResultSet> wrapper = (InvalidatableWrapper<ResultSet>) resultSet; |
411 | | - close( wrapper.getWrappedObject() ); |
412 | | - wrapper.invalidate(); |
413 | | - return; |
414 | | - } |
415 | | - |
416 | | - try { |
417 | | - resultSet.close(); |
418 | | - } |
419 | | - catch ( Exception e ) { |
420 | | - // try to handle general errors more elegantly |
421 | | - LOG.debugf( "Unable to release JDBC result set [%s]", e.getMessage() ); |
422 | | - } |
423 | | - } |
424 | | - |
425 | 358 | @Override |
426 | 359 | public boolean isActive() { |
427 | 360 | return owner.getJdbcSessionContext().isActive(); |
|
0 commit comments