comparison src/main/java/org/monetdb/jdbc/MonetDriver.java @ 809:aa4108a5bc34 monetdbs

Move more URL and properties parsing responsibilities to Target
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Tue, 12 Dec 2023 12:03:24 +0100 (17 months ago)
parents 04a27386789f
children 5aa19bbed0d6
comparison
equal deleted inserted replaced
808:6b7778153d23 809:aa4108a5bc34
104 { 104 {
105 // url should be of style jdbc:monetdb://<host>/<database> 105 // url should be of style jdbc:monetdb://<host>/<database>
106 if (!acceptsURL(url)) 106 if (!acceptsURL(url))
107 return null; 107 return null;
108 108
109 Target target = new Target();
110
111 try { 109 try {
112 // If properties are given, add those first 110 Target target = new Target(url, info);
113 if (info != null) { 111 return new MonetConnection(target);
114 for (String key : info.stringPropertyNames()) {
115 String value = info.getProperty(key);
116 if (key.equals(Parameter.HOST.name))
117 value = Target.unpackHost(value);
118 target.setString(key, value);
119 }
120 }
121
122 // If url is exactly "jdbc:monetdb:", use just the properties.
123 // This is different from, say, jdbc:monetdb://, because the
124 // latter will clear preexisting host, port, TLS and database settings.
125 // Useful in combination with Target.toProperties().
126 if (!url.equals("jdbc:monetdb:"))
127 MonetUrlParser.parse(target, url.substring(5));
128 } catch (ValidationError | URISyntaxException e) { 112 } catch (ValidationError | URISyntaxException e) {
129 throw new SQLException(e.getMessage()); 113 throw new SQLException(e.getMessage());
130 } 114 }
131
132 // finally return the Connection object as requested
133 return new MonetConnection(target);
134 } 115 }
135 116
136 /** 117 /**
137 * Retrieves the driver's major version number. Initially this should be 1. 118 * Retrieves the driver's major version number. Initially this should be 1.
138 * 119 *