diff src/main/java/org/monetdb/jdbc/MonetPreparedStatement.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 6aa38e8c0f2d
children 71bcc7af90be
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java
+++ b/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java
@@ -2692,28 +2692,24 @@ public class MonetPreparedStatement
 	 */
 	@Override
 	public void close() {
-		try {
-			if (!closed && id != -1)
+		if (!closed && id != -1) {
+			try {
 				connection.sendControlCommand("release " + id);
-		} catch (SQLException e) {
-			// probably server closed connection
+			} catch (SQLException e) {
+				// probably server closed connection
+			}
 		}
+		clearParameters();
+		mTimestampZ = null;
+		mTimestamp = null;
+		mTimeZ = null;
+		mTime = null;
+		mDate = null;
+		execStmt = null;
 		super.close();
 	}
 
 	/**
-	 * Call close to release the server-sided handle for this
-	 * PreparedStatement.
-	 *
-	 * @deprecated (since="9")
-	 */
-	@Override
-	@Deprecated
-	protected void finalize() {
-		close();
-	}
-
-	/**
 	 * Return the prepared SQL statement including parameter types and parameter values that were set.
 	 *
 	 * @return a String representing this Object