diff 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
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java
@@ -432,7 +432,14 @@ public class MonetConnection
 	 */
 	@Override
 	public void close() {
+		if (closed)
+			return;
+
+		clearWarnings();
+		dbmd = null;
 		synchronized (server) {
+			// Note: An entry in a WeakHashMap will automatically be
+			// removed when its key is no longer in ordinary use.
 			for (Statement st : statements.keySet()) {
 				try {
 					st.close();
@@ -2587,7 +2594,8 @@ public class MonetConnection
 		 */
 		@Override
 		public void close() {
-			if (closed) return;
+			if (closed)
+				return;
 
 			// send command to server indicating we're done with this
 			// result only if we had an ID in the header and this result
@@ -2605,7 +2613,12 @@ public class MonetConnection
 				if (r != null)
 					r.close();
 			}
-
+			name = null;
+			type = null;
+			columnLengths = null;
+			tableNames = null;
+			schemaNames = null;
+			resultBlocks = null;
 			closed = true;
 		}