Commons Dbcp
  1. Commons Dbcp
  2. DBCP-402

Add a way to set an instance of java.sql.Driver directly on org.apache.commons.dbcp2.BasicDataSource


    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Labels:


      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].



        Ben Hale created issue -
        Mark Thomas made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0 [ 12313721 ]
        Resolution Fixed [ 1 ]
        Phil Steitz made changes -
        Status Resolved [ 5 ] Closed [ 6 ]


          • Assignee:
            Ben Hale
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: