Issue Details (XML | Word | Printable)

Key: DBCP-36
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Jonathan Whitall
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Dbcp

BasicDataSource does not work with getConnection(String, String)

Created: 08/Jul/04 06:10 AM   Updated: 25/Mar/08 08:11 AM
Return to search
Component/s: None
Affects Version/s: 1.2
Fix Version/s: None

Time Tracking:
Not Specified

Environment:
Operating System: Windows XP
Platform: PC

Bugzilla Id: 29963


 Description  « Hide
Using DBCP 1.2.1, I cannot get a BasicDataSource to work when credentials are
not supplied. My application learns the username and password at runtime and
as a result has to use getConnection(String, String). The problem seems to
occur in the createDataSource() method.

If a username and password are not supplied with the data source, they get
logged as missing, which is fine, but in the absence of the username/password
upon creation of the ConnectionPoolFactory, it bombs upon validation. Since
createDataSource() is called without arguments regardless of the getConnection()
method that is called, validateConnectionFactory(PoolableConnectionFactory)
will always fail if the username and password are not supplied with the
original data source configuration.

My application runs outside of an application server. I am using Spring 1.0 and
have tried HSQL and MySQL JDBC drivers. I can reproduce this error.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dirk Verbeeck added a comment - 09/Jul/04 12:31 AM
BasicDataSource only supports the getConnection() method with the
username/password set globally on the datasource.

If you want to use getConnection(String username, String password)
then you should use the org.apache.commons.dbcp.datasources.PerUserPoolDataSource


Jonathan Whitall added a comment - 09/Jul/04 01:18 AM
If a BasicDataSource claims to implement a javax.sql.DataSource, it needs to
implement all of javax.sql.DataSource's methods correctly, or else throw an
UnsupportedOperationException if the implementation chooses not to support such
operation (as in this case). Nowhere does the JavaDoc suggest that this
operation isn't supported for this class.

Dirk Verbeeck added a comment - 11/Jul/04 11:55 PM
Suggested code & javadoc enhancements implemented in revision 1.38
  • fail fast (throw UnsupportedOperationException)
  • update javadoc

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSource.java?r1=1.37&r2=1.38&diff_format=h