|
|
|
@ -29,12 +29,17 @@ public class DriverDataSource implements DataSource {
|
|
|
|
|
|
|
|
|
|
private Driver driver;
|
|
|
|
|
|
|
|
|
|
public DriverDataSource(String jdbcUrl, String driverClassName, Properties properties, String username, String password) {
|
|
|
|
|
public DriverDataSource(String jdbcUrl,
|
|
|
|
|
String driverClassName,
|
|
|
|
|
Properties properties,
|
|
|
|
|
String username,
|
|
|
|
|
String password) {
|
|
|
|
|
this.jdbcUrl = jdbcUrl;
|
|
|
|
|
this.driverProperties = new Properties();
|
|
|
|
|
for (Entry<Object, Object> entry : properties.entrySet()) {
|
|
|
|
|
driverProperties.setProperty(entry.getKey().toString(), entry.getValue().toString());
|
|
|
|
|
}
|
|
|
|
|
logger.log(Level.INFO, "DriverManager looking for JDBC URL " + jdbcUrl);
|
|
|
|
|
if (username != null) {
|
|
|
|
|
setUser(username);
|
|
|
|
|
}
|
|
|
|
@ -51,25 +56,25 @@ public class DriverDataSource implements DataSource {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (driver == null) {
|
|
|
|
|
logger.warning("Registered driver with driverClassName was not found, trying direct instantiation: " + driverClassName);
|
|
|
|
|
logger.log(Level.WARNING, "Registered driver with driverClassName was not found, trying direct instantiation: " + driverClassName);
|
|
|
|
|
Class<?> driverClass = null;
|
|
|
|
|
ClassLoader threadContextClassLoader = Thread.currentThread().getContextClassLoader();
|
|
|
|
|
try {
|
|
|
|
|
if (threadContextClassLoader != null) {
|
|
|
|
|
try {
|
|
|
|
|
driverClass = threadContextClassLoader.loadClass(driverClassName);
|
|
|
|
|
logger.fine("Driver class found in Thread context class loader: " + driverClassName + " " + threadContextClassLoader);
|
|
|
|
|
logger.log(Level.FINE, "Driver class found in Thread context class loader: " + driverClassName + " " + threadContextClassLoader);
|
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
|
logger.fine("Driver class not found in Thread context class loader, trying classloader: " +
|
|
|
|
|
logger.log(Level.FINE, "Driver class not found in Thread context class loader, trying classloader: " +
|
|
|
|
|
driverClassName + " " + threadContextClassLoader + " " + this.getClass().getClassLoader());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (driverClass == null) {
|
|
|
|
|
driverClass = this.getClass().getClassLoader().loadClass(driverClassName);
|
|
|
|
|
logger.fine("Driver class found in the PoolConfig class classloader:" + driverClassName + " " + this.getClass().getClassLoader());
|
|
|
|
|
logger.log(Level.FINE, "Driver class found in the PoolConfig class classloader:" + driverClassName + " " + this.getClass().getClassLoader());
|
|
|
|
|
}
|
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
|
logger.fine("Failed to load driver class from PoolConfig class classloader: " + driverClassName + " " + this.getClass().getClassLoader());
|
|
|
|
|
logger.log(Level.FINE, "Failed to load driver class from PoolConfig class classloader: " + driverClassName + " " + this.getClass().getClassLoader());
|
|
|
|
|
}
|
|
|
|
|
if (driverClass != null) {
|
|
|
|
|
try {
|
|
|
|
@ -84,7 +89,7 @@ public class DriverDataSource implements DataSource {
|
|
|
|
|
try {
|
|
|
|
|
if (driver == null) {
|
|
|
|
|
driver = DriverManager.getDriver(jdbcUrl);
|
|
|
|
|
logger.fine("Loaded driver with class name for jdbcUrl " + driver.getClass().getName() + " " + sanitizedUrl);
|
|
|
|
|
logger.log(Level.FINE, "Loaded driver with class name for jdbcUrl " + driver.getClass().getName() + " " + sanitizedUrl);
|
|
|
|
|
} else if (!driver.acceptsURL(jdbcUrl)) {
|
|
|
|
|
throw new RuntimeException("Driver " + driverClassName + " claims to not accept jdbcUrl " + sanitizedUrl);
|
|
|
|
|
}
|
|
|
|
|