Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load real driver class before use #31

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -176,6 +176,20 @@ private void setProperties() {
this.realDriverClass = this.config.getStringPropertyWithDefault("realDriverClass", getDefaultDriverClass());
}

/**
* Loads the real driver.
*
* @throws IllegalStateException When there is no class with the name
* <code>realDriverClass</code>
*/
private void loadRealDriver() {
try {
Class.forName(this.realDriverClass);
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Could not load real driver with name, \"" + this.realDriverClass + "\".", e);
}
}

/**
* Called when the driver is deregistered to cleanup resources.
*/
@@ -234,6 +248,7 @@ private String unwrapUrl(String jdbcUrl) {
* <code>realDriverClass</code>
*/
public Driver getWrappedDriver() {
loadRealDriver();
Enumeration<Driver> availableDrivers = DriverManager.getDrivers();
while (availableDrivers.hasMoreElements()) {
Driver driver = availableDrivers.nextElement();