Details
-
Bug
-
Resolution: Fixed
-
P3
-
8
-
None
-
b108
-
generic
-
generic
Description
When a connection is established (calling DriverManager.getConnection) the driver is not resolved. Whatever the way the Driver is registered (system property, classloading and direct registration), connection is failing.
When getConnection is called, the DriverManager retrieves the caller classloader (3 frames upper) and uses this classloader to load the driver. This is failing.
A simple testcase based on derby driver, the getDrivers should return an enumeration containing 1 element, the returned enumeration is empty:
var type = Packages.org.apache.derby.jdbc.ClientDriver;
var tt = new type();
Packages.java.sql.DriverManager.registerDriver(tt);
print(Packages.java.sql.DriverManager.getDrivers().hasMoreElements());
When getConnection is called, the DriverManager retrieves the caller classloader (3 frames upper) and uses this classloader to load the driver. This is failing.
A simple testcase based on derby driver, the getDrivers should return an enumeration containing 1 element, the returned enumeration is empty:
var type = Packages.org.apache.derby.jdbc.ClientDriver;
var tt = new type();
Packages.java.sql.DriverManager.registerDriver(tt);
print(Packages.java.sql.DriverManager.getDrivers().hasMoreElements());