comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 623:1c3cdf0667d7

Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects. Remove deprecated finalize() method from MonetPreparedStatement. finalize() is deprecated from Java 9 onwards.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 20 Jan 2022 13:00:00 +0100 (2022-01-20)
parents 5ab170ddc66a
children 06d69b82d409
comparison
equal deleted inserted replaced
622:61877c1f19f6 623:1c3cdf0667d7
430 * Calling the method close on a Connection object that is already 430 * Calling the method close on a Connection object that is already
431 * closed is a no-op. 431 * closed is a no-op.
432 */ 432 */
433 @Override 433 @Override
434 public void close() { 434 public void close() {
435 if (closed)
436 return;
437
438 clearWarnings();
439 dbmd = null;
435 synchronized (server) { 440 synchronized (server) {
441 // Note: An entry in a WeakHashMap will automatically be
442 // removed when its key is no longer in ordinary use.
436 for (Statement st : statements.keySet()) { 443 for (Statement st : statements.keySet()) {
437 try { 444 try {
438 st.close(); 445 st.close();
439 } catch (SQLException e) { 446 } catch (SQLException e) {
440 // better luck next time! 447 // better luck next time!
2585 * Closes this Response by sending an Xclose to the server indicating 2592 * Closes this Response by sending an Xclose to the server indicating
2586 * that the result can be closed at the server side as well. 2593 * that the result can be closed at the server side as well.
2587 */ 2594 */
2588 @Override 2595 @Override
2589 public void close() { 2596 public void close() {
2590 if (closed) return; 2597 if (closed)
2598 return;
2591 2599
2592 // send command to server indicating we're done with this 2600 // send command to server indicating we're done with this
2593 // result only if we had an ID in the header and this result 2601 // result only if we had an ID in the header and this result
2594 // was larger than the reply size 2602 // was larger than the reply size
2595 try { 2603 try {
2603 for (int i = 1; i < resultBlocks.length; i++) { 2611 for (int i = 1; i < resultBlocks.length; i++) {
2604 DataBlockResponse r = resultBlocks[i]; 2612 DataBlockResponse r = resultBlocks[i];
2605 if (r != null) 2613 if (r != null)
2606 r.close(); 2614 r.close();
2607 } 2615 }
2608 2616 name = null;
2617 type = null;
2618 columnLengths = null;
2619 tableNames = null;
2620 schemaNames = null;
2621 resultBlocks = null;
2609 closed = true; 2622 closed = true;
2610 } 2623 }
2611 2624
2612 /** 2625 /**
2613 * Returns whether this Response is closed 2626 * Returns whether this Response is closed