You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Jonathan Whitall <fi...@yahoo.com> on 2004/07/06 23:04:13 UTC

[DBCP] Issue with BasicDataSource when username and pw not supplied

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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [DBCP] Issue with BasicDataSource when username and pw not supplied

Posted by Dirk Verbeeck <di...@pandora.be>.
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

-- 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: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org