If you want to use getConnection(String username, String password)
then you should use the org.apache.commons.dbcp.datasources.PerUserPoolDataSource
-- Dirk
Jonathan Whitall wrote:
Hello,
I using DBCP 1.2.1 and am having a great deal of trouble getting a BasicDataSource to initialize when I do not supply a username and password to the data source configuration. In this case, my application learns the username and password at runtime. The problem seems to be upon initialization of the data source when I call getConnection(String username, String password), specifically the call to 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/pw 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.
I have tested this scenario with both HSQL and MySQL drivers. If I provide the username and password on the data source configuration, however, they both work fine. Here is the stack trace that I get when I use HSQL:
org.springframework.jdbc.support.MetaDataAccessException: Error while getting connection; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Connection is broken: Software caused connection abort: socket write error) org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Connection is broken: Software caused connection abort: socket write error) org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Connection is broken: Software caused connection abort: socket write error) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:554) ...
Any help would be appreciated.
Thanks, Jonathan
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
