comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 658:108123ca6889

Add autocommit=true/false option to jdbc url
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Fri, 09 Sep 2022 15:20:55 +0200 (2022-09-09)
parents 8476d6f4378f
children 7ec8d469fd0b
comparison
equal deleted inserted replaced
657:8476d6f4378f 658:108123ca6889
208 208
209 final String hash = props.getProperty("hash"); 209 final String hash = props.getProperty("hash");
210 if (hash != null) 210 if (hash != null)
211 conn_props.setProperty("hash", hash); 211 conn_props.setProperty("hash", hash);
212 212
213 String autocommit_prop = props.getProperty("autocommit");
214 boolean initial_autocommit = true;
215 if (autocommit_prop != null) {
216 initial_autocommit = Boolean.parseBoolean(autocommit_prop);
217 conn_props.setProperty("initial_autocommit", Boolean.toString(initial_autocommit));
218 }
219
213 final String fetchsize_prop = props.getProperty("fetchsize"); 220 final String fetchsize_prop = props.getProperty("fetchsize");
214 if (fetchsize_prop != null) { 221 if (fetchsize_prop != null) {
215 try { 222 try {
216 int fetchsize = Integer.parseInt(fetchsize_prop); 223 int fetchsize = Integer.parseInt(fetchsize_prop);
217 if (fetchsize > 0 || fetchsize == -1) { 224 if (fetchsize > 0 || fetchsize == -1) {
286 293
287 final Calendar cal = Calendar.getInstance(); 294 final Calendar cal = Calendar.getInstance();
288 int offsetMillis = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); 295 int offsetMillis = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
289 int offsetSeconds = offsetMillis / 1000; 296 int offsetSeconds = offsetMillis / 1000;
290 final HandshakeOptions handshakeOptions = new HandshakeOptions(); 297 final HandshakeOptions handshakeOptions = new HandshakeOptions();
298 handshakeOptions.set(Setting.AutoCommit, initial_autocommit ? 1 : 0);
291 handshakeOptions.set(Setting.TimeZone, offsetSeconds); 299 handshakeOptions.set(Setting.TimeZone, offsetSeconds);
292 handshakeOptions.set(Setting.ReplySize, defaultFetchSize); 300 handshakeOptions.set(Setting.ReplySize, defaultFetchSize);
293 // handshakeOptions.set(Setting.SizeHeader, 1); 301 // handshakeOptions.set(Setting.SizeHeader, 1);
294 server.setHandshakeOptions(handshakeOptions); 302 server.setHandshakeOptions(handshakeOptions);
295 303
386 } 394 }
387 } 395 }
388 396
389 // the following initialisers are only valid when the language is SQL... 397 // the following initialisers are only valid when the language is SQL...
390 if (lang == LANG_SQL) { 398 if (lang == LANG_SQL) {
391 // enable auto commit 399 if (handshakeOptions.mustSend(Setting.AutoCommit)) {
392 setAutoCommit(true); 400 setAutoCommit(handshakeOptions.get(Setting.AutoCommit) != 0);
401 }
393 402
394 // set our time zone on the server, if we haven't already 403 // set our time zone on the server, if we haven't already
395 if (handshakeOptions.mustSend(Setting.TimeZone)) { 404 if (handshakeOptions.mustSend(Setting.TimeZone)) {
396 final StringBuilder tz = new StringBuilder(64); 405 final StringBuilder tz = new StringBuilder(64);
397 tz.append("SET TIME ZONE INTERVAL '"); 406 tz.append("SET TIME ZONE INTERVAL '");
1820 name.equals("debug") || 1829 name.equals("debug") ||
1821 name.equals("logfile") || 1830 name.equals("logfile") ||
1822 name.equals("hash") || 1831 name.equals("hash") ||
1823 name.equals("treat_blob_as_binary") || 1832 name.equals("treat_blob_as_binary") ||
1824 name.equals("treat_clob_as_varchar") || 1833 name.equals("treat_clob_as_varchar") ||
1834 name.equals("autocommit") ||
1825 name.equals("so_timeout") || 1835 name.equals("so_timeout") ||
1826 name.equals("fetchsize"); // only supported by servers from version 11.41.1 onwards 1836 name.equals("fetchsize"); // only supported by servers from version 11.41.1 onwards
1827 } 1837 }
1828 1838
1829 1839