java/sql-dk/src/info/globalcode/sql/dk/configuration/Loader.java
branchv_0
changeset 196 76da38d49e81
parent 194 629c9c7eab01
child 236 a3ec71fa8e17
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Loader.java	Sun May 17 15:43:20 2015 +0200
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Loader.java	Mon May 18 00:33:10 2015 +0200
     1.3 @@ -78,7 +78,13 @@
     1.4  			try {
     1.5  				Class<Driver> driverClass = (Class<Driver>) Class.forName(driverClassName);
     1.6  				Driver driver = driverClass.newInstance();
     1.7 -				return driver.connect(url, javaProperties);
     1.8 +				Connection connection = driver.connect(url, javaProperties);
     1.9 +				if (connection == null) {
    1.10 +					log.log(Level.SEVERE, "Driver „{0}“ returend null → it does not accept the URL: „{1}“", new Object[]{driverClassName, url});
    1.11 +					throw new SQLException("Unable to connect: driver returned null.");
    1.12 +				} else {
    1.13 +					return connection;
    1.14 +				}
    1.15  			} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) {
    1.16  				throw new SQLException("Unable to connect usig specific driver: " + driverClassName, e);
    1.17  			}