Issue1925

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

Created on 2012-06-15.18:10:06 by tcrawley, last changed 2013-02-20.00:32:42 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
jdbc_driver_fallback.patch tcrawley, 2012-06-15.18:10:05
Messages
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: http://www.kfu.com/~nsayer/Java/dyn-jdbc.html

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.
History
Date User Action Args
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