Title: Support loading java.sql.Drivers that aren't on the boot classpath
Type: Severity: normal
Components: zxjdbc Versions: Jython 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: amak, fwierzbicki, jeff.allen, tcrawley, zyasoft
Priority: normal Keywords: patch

Created on 2012-06-15.18:10:06 by tcrawley, last changed 2018-03-17.06:01:52 by jeff.allen.

File name Uploaded Description Edit Remove
jdbc_driver_fallback.patch tcrawley, 2012-06-15.18:10:05
msg7227 (view) Author: Toby Crawley (tcrawley) Date: 2012-06-15.18:10:05
The attached patch adds support for creating JDBC connections for driver classes that aren't 
available from the system classloader but are available in the sys classloader.

The problem: java.sql.DriverManager won't create connections for drivers that aren't loaded 
in the system classloader, making it difficult to load driver classes dynamically.

A common solution is to use a delegating driver class that can handle the dynamic driver, as 
described here:

This patch works around that, and saves the user from using the delegation approach. It
modifies zxJDBC.connect to first attempt to use DriverManager.getConnection with a fallback 
to instantiate the driver and call connect() directly. It also attempts to load the driver
class in the system state classloader instead of the system classloader.

The patch has a null check around Py.getSystemState().getClassLoader(), but will that ever 
be null? I'm new to the jython codebase, so the state of that classloader is unclear to me.
msg7383 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-08-10.21:27:34
Thanks for the patch Toby, I will try to have a look after the 2.5.3 final cycle.
msg9049 (view) Author: Jim Baker (zyasoft) Date: 2014-09-26.06:04:20
Likely goes away as a problem with the adoption of jyjdbc to replace zxJDBC, since that will be using Jython's class loader
msg11815 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-17.06:01:52
Anybody know if this is still an issue (assuming only 2.7 is supported)?
Date User Action Args
2018-03-17 06:01:52jeff.allensetnosy: + jeff.allen
messages: + msg11815
2014-09-26 06:04:20zyasoftsetnosy: + zyasoft
messages: + msg9049
2013-02-20 00:32:42fwierzbickisetversions: + Jython 2.7, - 2.7a2
2013-02-15 19:45:35amaksetnosy: + amak
2012-08-10 21:27:34fwierzbickisetmessages: + msg7383
2012-06-28 18:42:08fwierzbickisetpriority: normal
assignee: fwierzbicki
2012-06-15 18:26:57fwierzbickisetnosy: + fwierzbicki
2012-06-15 18:10:06tcrawleycreate