comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 429:e4e104f8146c

Add fetchsize to the list of valid client props Also, check these in the constructor, not just in .setClientInfo()
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Mon, 08 Feb 2021 14:06:42 +0100 (2021-02-08)
parents 0b808a4d4f1f
children f24b59110a7f
comparison
equal deleted inserted replaced
428:0b808a4d4f1f 429:e4e104f8146c
264 // fallback to default language: sql 264 // fallback to default language: sql
265 language = "sql"; 265 language = "sql";
266 addWarning("No language specified, defaulting to 'sql'", "M1M05"); 266 addWarning("No language specified, defaulting to 'sql'", "M1M05");
267 } 267 }
268 268
269 // warn about unrecognized settings
270 for (Entry<Object,Object> e: props.entrySet()) {
271 checkValidProperty(e.getKey().toString(), "MonetConnection");
272 }
273
269 server = new MapiSocket(); 274 server = new MapiSocket();
270 if (hash != null) 275 if (hash != null)
271 server.setHash(hash); 276 server.setHash(hash);
272 if (database != null) 277 if (database != null)
273 server.setDatabase(database); 278 server.setDatabase(database);
1457 if (value == null) { 1462 if (value == null) {
1458 if (conn_props.containsKey(name)) 1463 if (conn_props.containsKey(name))
1459 conn_props.remove(name); 1464 conn_props.remove(name);
1460 return; 1465 return;
1461 } 1466 }
1462 // only set value for supported property names 1467 // only set value for supported property names, warn about the others
1463 if (name.equals("host") || 1468 if (checkValidProperty(name, "setClientInfo"))
1464 name.equals("port") ||
1465 name.equals("user") ||
1466 name.equals("password") ||
1467 name.equals("database") ||
1468 name.equals("language") ||
1469 name.equals("so_timeout") ||
1470 name.equals("debug") ||
1471 name.equals("hash") ||
1472 name.equals("treat_blob_as_binary") ||
1473 name.equals("treat_clob_as_varchar"))
1474 { 1469 {
1475 conn_props.setProperty(name, value); 1470 conn_props.setProperty(name, value);
1476 } else {
1477 addWarning("setClientInfo: " + name + "is not a recognised property", "01M07");
1478 } 1471 }
1479 } 1472 }
1480 1473
1481 /** 1474 /**
1482 * Sets the value of the connection's client info properties. 1475 * Sets the value of the connection's client info properties.
1508 setClientInfo(entry.getKey().toString(), entry.getValue().toString()); 1501 setClientInfo(entry.getKey().toString(), entry.getValue().toString());
1509 } 1502 }
1510 } 1503 }
1511 } 1504 }
1512 1505
1506 private boolean checkValidProperty(String name, String context) {
1507 boolean valid = checkValidProperty(name);
1508 if (!valid) {
1509 addWarning(java.lang.String.format("%s: '%s' is not a recognised property", context, name), "01M07");
1510 }
1511 return valid;
1512 }
1513
1514 private boolean checkValidProperty(String name) {
1515 return name.equals("host") ||
1516 name.equals("port") ||
1517 name.equals("user") ||
1518 name.equals("password") ||
1519 name.equals("database") ||
1520 name.equals("language") ||
1521 name.equals("so_timeout") ||
1522 name.equals("debug") ||
1523 name.equals("hash") ||
1524 name.equals("treat_blob_as_binary") ||
1525 name.equals("treat_clob_as_varchar") ||
1526 name.equals("fetchsize") ||
1527 name.equals("logfile")
1528 ;
1529 }
1513 1530
1514 //== Java 1.7 methods (JDBC 4.1) 1531 //== Java 1.7 methods (JDBC 4.1)
1515 1532
1516 /** 1533 /**
1517 * Sets the given schema name to access. 1534 * Sets the given schema name to access.