Bug 48773

Summary: DataSourceWrapper and DriverManager problems
Product: Taglibs Reporter: Jarek Gawor <jgawor>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: nightly   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Patch for this issue.

Description Jarek Gawor 2010-02-19 04:58:17 UTC
Created attachment 25022 [details]
Patch for this issue.

In certain situations the DataSourceWrapper is not able to connect to the database even if a driver class name was explicitly set. The core of the problem is that the DriverManager uses the caller's classloader (in this case the classloader of DataSourceWrapper) to find a driver for the given url. In some cases the classloader of DataSourceWrapper might be totally different and separate from the context classloader that registered the driver with DriverManager. In these cases the DriverManager will not "see" the driver registered earlier because of the different classloaders and the DataSourceWrapper.getConnection() will fail with "unable to find suitable driver" type of error message.

One easy work solution for this problem is to actually use the driver object that was registered in setDriverClassName() to connect to the database. And if the connection fails then fallback to using the DriverManager API.
Comment 1 Jeremy Boynes 2010-10-09 18:28:25 UTC
Patch applied as r1006229.
Thanks