java/sql-dk/src/info/globalcode/sql/dk/configuration/Loader.java
branchv_0
changeset 196 76da38d49e81
parent 194 629c9c7eab01
child 236 a3ec71fa8e17
equal deleted inserted replaced
195:aed11d9107bf 196:76da38d49e81
    76 		} else {
    76 		} else {
    77 			log.log(Level.FINE, "Using custom Driver „{0}“ to create connection for „{1}“", new Object[]{driverClassName, url});
    77 			log.log(Level.FINE, "Using custom Driver „{0}“ to create connection for „{1}“", new Object[]{driverClassName, url});
    78 			try {
    78 			try {
    79 				Class<Driver> driverClass = (Class<Driver>) Class.forName(driverClassName);
    79 				Class<Driver> driverClass = (Class<Driver>) Class.forName(driverClassName);
    80 				Driver driver = driverClass.newInstance();
    80 				Driver driver = driverClass.newInstance();
    81 				return driver.connect(url, javaProperties);
    81 				Connection connection = driver.connect(url, javaProperties);
       
    82 				if (connection == null) {
       
    83 					log.log(Level.SEVERE, "Driver „{0}“ returend null → it does not accept the URL: „{1}“", new Object[]{driverClassName, url});
       
    84 					throw new SQLException("Unable to connect: driver returned null.");
       
    85 				} else {
       
    86 					return connection;
       
    87 				}
    82 			} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) {
    88 			} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) {
    83 				throw new SQLException("Unable to connect usig specific driver: " + driverClassName, e);
    89 				throw new SQLException("Unable to connect usig specific driver: " + driverClassName, e);
    84 			}
    90 			}
    85 		}
    91 		}
    86 	}
    92 	}