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