Mercurial > hg > monetdb-java
comparison src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in @ 254:27b7166860c8
According to the JDBC specification if the JDBC URL is invalid, return null instead of an exception, so the DriverManager can keep looking for a suitable JDBC driver.
author | Pedro Ferreira <pedro.ferreira@monetdbsolutions.com> |
---|---|
date | Fri, 09 Nov 2018 10:59:36 +0100 (2018-11-09) |
parents | ea729e0cf24d |
children | 96057ee68017 d4baf8a4b43a |
comparison
equal
deleted
inserted
replaced
253:1b8277de9a7d | 254:27b7166860c8 |
---|---|
114 public Connection connect(String url, Properties info) | 114 public Connection connect(String url, Properties info) |
115 throws SQLException | 115 throws SQLException |
116 { | 116 { |
117 // url should be of style jdbc:monetdb://<host>/<database> | 117 // url should be of style jdbc:monetdb://<host>/<database> |
118 if (!acceptsURL(url)) | 118 if (!acceptsURL(url)) |
119 throw new SQLNonTransientConnectionException("Invalid URL: it does not start with: " + MONETURL, "08M26"); | 119 return null; |
120 | 120 |
121 Properties props = new Properties(); | 121 Properties props = new Properties(); |
122 // set the optional properties and their defaults here | 122 // set the optional properties and their defaults here |
123 props.put("port", PORT); | 123 props.put("port", PORT); |
124 props.put("debug", "false"); | 124 props.put("debug", "false"); |
132 // remove leading "jdbc:" so the rest is a valid hierarchical URI | 132 // remove leading "jdbc:" so the rest is a valid hierarchical URI |
133 URI uri; | 133 URI uri; |
134 try { | 134 try { |
135 uri = new URI(url.substring(5)); | 135 uri = new URI(url.substring(5)); |
136 } catch (URISyntaxException e) { | 136 } catch (URISyntaxException e) { |
137 throw new SQLNonTransientConnectionException(e.toString(), "08M26"); | 137 return null; |
138 } | 138 } |
139 | 139 |
140 String uri_host = uri.getHost(); | 140 String uri_host = uri.getHost(); |
141 if (uri_host == null) | 141 if (uri_host == null) |
142 throw new SQLNonTransientConnectionException("Invalid URL: no hostname given or unparsable in '" + url + "'", "08M26"); | 142 return null; |
143 info.put("host", uri_host); | 143 info.put("host", uri_host); |
144 | 144 |
145 int uri_port = uri.getPort(); | 145 int uri_port = uri.getPort(); |
146 if (uri_port > 0) | 146 if (uri_port > 0) |
147 info.put("port", Integer.toString(uri_port)); | 147 info.put("port", Integer.toString(uri_port)); |