You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Mark Thomas (JIRA)" <ji...@apache.org> on 2013/10/30 15:19:29 UTC
[jira] [Commented] (DBCP-402) Add a way to set an instance of
java.sql.Driver directly on org.apache.commons.dbcp2.BasicDataSource
[ https://issues.apache.org/jira/browse/DBCP-402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13809128#comment-13809128 ]
Mark Thomas commented on DBCP-402:
----------------------------------
It isn't as clean a solution but you are already able to specify the class loader to use to load the Driver.
> Add a way to set an instance of java.sql.Driver directly on org.apache.commons.dbcp2.BasicDataSource
> ----------------------------------------------------------------------------------------------------
>
> Key: DBCP-402
> URL: https://issues.apache.org/jira/browse/DBCP-402
> Project: Commons Dbcp
> Issue Type: Improvement
> Affects Versions: 2.0
> Reporter: Ben Hale
>
> Currently when org.apache.commons.dbcp2.BasicDataSource is directly instantiated (e.g. in an IoC environment), the only way to set the type of java.sql.Driver that is should use is by passing in a String classname which is then passed to DriverManager. The downside to this is that it requires the DataSource and the Driver to be in the same classloader. In practice many times the Driver is in the application classloader while the DataSource is in the container classloader meaning that other than packaging a Tomcat JAR in your application you cannot use the DataSource directly.
> It'd be great to have a way to pass the actual instance of Driver to the DataSource and have it use that instead of going to DriverManager to find it. This would enable standard classloader inheritance to work properly and allow the non-adjacent packaging of the Driver and DataSource.
> An example of this style of configuration can be found in Spring's SimpleDriverDataSource[1].
> [1]: http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/jdbc/datasource/SimpleDriverDataSource.html#setDriver(java.sql.Driver)
--
This message was sent by Atlassian JIRA
(v6.1#6144)