Changeset: 04a27386789f for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/04a27386789f
Modified Files:
src/main/java/org/monetdb/jdbc/MonetDriver.java
Branch: monetdbs
Log Message:
MonetDriver: Use only the properties if URL is exactly "jdbc:monetdb:"
Normally, parsing the URL clears host, port, etc.
That means that an application that already has everything as Properties
has to extract those from the Properties and construct a URL,
which is inconvenient and error-prone.
diffs (39 lines):
diff --git a/src/main/java/org/monetdb/jdbc/MonetDriver.java
b/src/main/java/org/monetdb/jdbc/MonetDriver.java
--- a/src/main/java/org/monetdb/jdbc/MonetDriver.java
+++ b/src/main/java/org/monetdb/jdbc/MonetDriver.java
@@ -70,7 +70,11 @@ public final class MonetDriver implement
*/
@Override
public boolean acceptsURL(final String url) {
- return url != null && url.startsWith("jdbc:monetdb://");
+ if (url == null)
+ return false;
+ if (url.startsWith("jdbc:monetdb:") ||
url.startsWith("jdbc:monetdbs:"))
+ return true;
+ return false;
}
/**
@@ -105,6 +109,7 @@ public final class MonetDriver implement
Target target = new Target();
try {
+ // If properties are given, add those first
if (info != null) {
for (String key : info.stringPropertyNames()) {
String value = info.getProperty(key);
@@ -113,7 +118,13 @@ public final class MonetDriver implement
target.setString(key, value);
}
}
- MonetUrlParser.parse(target, url.substring(5));
+
+ // If url is exactly "jdbc:monetdb:", use just the
properties.
+ // This is different from, say, jdbc:monetdb://,
because the
+ // latter will clear preexisting host, port, TLS and
database settings.
+ // Useful in combination with Target.toProperties().
+ if (!url.equals("jdbc:monetdb:"))
+ MonetUrlParser.parse(target, url.substring(5));
} catch (ValidationError | URISyntaxException e) {
throw new SQLException(e.getMessage());
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]