changeset 751:1566dbfaa13b

Correct setQueryTimeout(secs) implementation. It was changed to match the web documentation (see https://dev.monetdb.org/hg/monetdb-java/rev/849f99124e32 ) but it appears the web documentation was wrong. So revert the changes made.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 23 Mar 2023 19:14:56 +0100 (2023-03-23)
parents 02ad91fb3438
children 9cceb0d73a66
files src/main/java/org/monetdb/jdbc/MonetConnection.java
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java
@@ -146,7 +146,7 @@ public class MonetConnection
 	private boolean treatClobAsVarChar = true;	// turned on by default for optimal performance (from JDBC Driver release 3.0 onwards)
 
 	/** The last set query timeout on the server as used by Statement, PreparedStatement and CallableStatement */
-	protected int lastSetQueryTimeout;	// 0 means no timeout, which is the default on the server
+	protected int lastSetQueryTimeout = 0;	// 0 means no timeout, which is the default on the server
 
 	/** A cache to reduce the number of DatabaseMetaData objects created by getMetaData() to maximum 1 per connection */
 	private DatabaseMetaData dbmd;
@@ -1787,14 +1787,13 @@ public class MonetConnection
 		Statement st = null;
 		try {
 			final String callstmt;
-			final int msecs = (seconds <= 2147483) ? seconds * 1000 : seconds;	// prevent overflow of int
-
-			// as of release Jun2020 (11.37.7) the function sys.settimeout(msecs bigint)
-			// is deprecated and replaced by new sys.setquerytimeout(msecs int)
+
+			// as of release Jun2020 (11.37.7) the function sys.settimeout(secs bigint)
+			// is deprecated and replaced by new sys.setquerytimeout(secs int)
 			if ((getDatabaseMajorVersion() == 11) && (getDatabaseMinorVersion() < 37))
-				callstmt = "CALL sys.\"settimeout\"(" + msecs + ")";
+				callstmt = "CALL sys.\"settimeout\"(" + seconds + ")";
 			else
-				callstmt = "CALL sys.\"setquerytimeout\"(" + msecs + ")";
+				callstmt = "CALL sys.\"setquerytimeout\"(" + seconds + ")";
 			// for debug: System.out.println("Before: " + callstmt);
 			st = createStatement();
 			st.execute(callstmt);