commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Heittman <rob.heitt...@solertium.com>
Subject Behavior of DBCP 1.4 BasicDataSource setDriverClassLoader(...)
Date Thu, 08 Jul 2010 00:47:43 GMT
Hi all,

It seems to me that the 1.4 behavior of BasicDataSource with regard to
setDriverClassLoader(...) is slightly off.  In my case -- using this to
enable DBCP to work better under some OSGi environments -- it doesn't have
the desired effect.  In createConnectionFactory() we have, essentially

            if (driverFromCCL == null) {
                // use DriverManager, which doesn't respect
driverClassLoader
                driver = DriverManager.getDriver(url);
            } else {
                // ... use the CCL to make our own Driver ...
            }

It's simple enough in my project to override createConnectionFactory(), but
wouldn't it be more predictable to do something like this?

            if (driverClassLoader !=null) {
                // ... use driverClassLoader to make our own Driver ...
            } else if (driverFromCCL == null) {
                // use a method that doesn't respect driverClassLoader
                driver = DriverManager.getDriver(url);
            } else {
                // ... use the CCL to make our own Driver ...
            }

Alternatively, a couple stanzas higher, we could set driverFromCCL if
driverClassLoader is used, which would trigger the correct behavior in this
(unmodified) section.

It seems like if somebody goes to the trouble to setDriverClassLoader(...)
they expect it to be used to load driver classes.  (I did)  If wiser heads
agree, happy to send a patch.

- Rob

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message