Message7227

Author tcrawley
Recipients tcrawley
Date 2012-06-15.18:10:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1339783806.35.0.227104842308.issue1925@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-06-15 18:10:06tcrawleysetrecipients: + tcrawley
2012-06-15 18:10:06tcrawleysetmessageid: <1339783806.35.0.227104842308.issue1925@psf.upfronthosting.co.za>
2012-06-15 18:10:06tcrawleylinkissue1925 messages
2012-06-15 18:10:05tcrawleycreate