Question

I was connecting to DB2 systems using org.apache.commons.dbcp.BasicDataSource and I have
found that com.ibm.db2.jcc.DB2DataSource is more extensive as it allows me to generate traces.

Now I would like to know the difference more accurately and which is preferable as I believe that BasicDataSource is light as compared to DB2DataSource.

Was it helpful?

Solution

org.apache.commons.dbcp.BasicDataSource is actually a connection pool, from which you can borrow/return connections to any flavour of database: Oracle, Sybase, DB2, etc.

com.ibm.db2.jcc.DB2DataSource is a DB2 data source.

So, you could have a DBCP pool of perhaps 100 DB2 connections. The pool will return you a pretty generic datasource for use in your code - unless you cast it explicitly to a DB2 one e.g. in order to get access to its fuller API. Edit following comment below: you shouldn't really need to do this, normal idiom of use is to go with the regular DataSource interface.

Read more about DBCP and its configuration options at:

http://commons.apache.org/proper/commons-dbcp/index.html

http://commons.apache.org/proper/commons-dbcp/configuration.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top