JDBC drivers: fix 'Unsupported URL' – drivers might be called witrh wrong URLs and then they should (according to the JavaDoc) return null instead of throwing an exception. v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 26 Feb 2019 17:31:41 +0100
branchv_0
changeset 2358ce612cca4d8
parent 234 305871254838
child 236 a3ec71fa8e17
JDBC drivers: fix 'Unsupported URL' – drivers might be called witrh wrong URLs and then they should (according to the JavaDoc) return null instead of throwing an exception.
This problem occurred when --test-connection was testing multiple connections in parallel.
java/jdbc-dk-driver/src/info/globalcode/sql/dk/jdbc/Driver.java
java/jdbc-loopback-driver/src/info/globalcode/jdbc/loopback/Driver.java
     1.1 --- a/java/jdbc-dk-driver/src/info/globalcode/sql/dk/jdbc/Driver.java	Tue Feb 26 16:36:45 2019 +0100
     1.2 +++ b/java/jdbc-dk-driver/src/info/globalcode/sql/dk/jdbc/Driver.java	Tue Feb 26 17:31:41 2019 +0100
     1.3 @@ -86,7 +86,8 @@
     1.4  				throw new SQLException("Unable to load SQL-DK configuration for name: " + name, e);
     1.5  			}
     1.6  		} else {
     1.7 -			throw new SQLException("Unsupported URL: " + url);
     1.8 +			// The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL.
     1.9 +			return null;
    1.10  		}
    1.11  	}
    1.12  
     2.1 --- a/java/jdbc-loopback-driver/src/info/globalcode/jdbc/loopback/Driver.java	Tue Feb 26 16:36:45 2019 +0100
     2.2 +++ b/java/jdbc-loopback-driver/src/info/globalcode/jdbc/loopback/Driver.java	Tue Feb 26 17:31:41 2019 +0100
     2.3 @@ -46,7 +46,8 @@
     2.4  		if (acceptsURL(url)) {
     2.5  			return new Connection(url, info);
     2.6  		} else {
     2.7 -			throw new SQLException("Unsupported URL: " + url);
     2.8 +			// The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL.
     2.9 +			return null;
    2.10  		}
    2.11  	}
    2.12