changeset 879:6e8ff2818fa7

Implement the new schema= option of the jdbc URL
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Wed, 28 Feb 2024 13:37:36 +0100 (13 months ago)
parents dc33533e6468
children 74b907f25564
files src/main/java/org/monetdb/jdbc/MonetConnection.java
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java
@@ -224,7 +224,7 @@ public class MonetConnection
 			throw sqle;
 		}
 
-		// Now take care of any handshake options not handled during the handshake
+		// Now take care of any options not handled during the handshake
 		curReplySize = defaultFetchSize;
 		if (lang == LANG_SQL) {
 			if (autoCommit != target.isAutocommit()) {
@@ -240,6 +240,13 @@ public class MonetConnection
 
 		// we're absolutely not closed, since we're brand new
 		closed = false;
+
+		if (!target.getSchema().isEmpty()) {
+			try (Statement stmt = this.createStatement()) {
+				String escaped = target.getSchema().replaceAll("\"", "\"\"");
+				stmt.execute("SET SCHEMA \"" + escaped + "\"");
+			}
+		}
 	}
 
 	//== methods of interface Connection