swaldman / c3p0

a mature, highly concurrent JDBC Connection pooling library, with support for caching and reuse of PreparedStatements.

Home Page:http://www.mchange.com/projects/c3p0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

password in null when using com.microsoft.sqlserver.jdbc.SQLServerDriver

sbaeumlisberger opened this issue · comments

When using the user and password properties with com.microsoft.sqlserver.jdbc.SQLServerDriver the password passed to the SQLServerDataSource connect method is null.

The cause of this issue is that in the C3P0ImplUtils class the password is retrieved form the nested data source, but the getter for the password in the SQLServerDataSource is not public. Therfore the readMethod is null and the password is not retrieved.

We are using osgi and the datasource config looks like that:

osgi.jdbc.driver.name=Microsoft JDBC Driver for SQL Server
osgi.jdbc.driver.class=com.microsoft.sqlserver.jdbc.SQLServerDriver

url=jdbc:sqlserver://localhost:1433;databaseName=devdb;
user=dbuser
password=dbpass

dataSourceName=ds

pool=c3p0
xa=false

jdbc.c3p0.dataSourceName=ds

Here I have attached a little standalone maven project to reproduce the issue:
project.zip

If you need more information, let me know.

I think that this addresses the issue! If we can read the user but only a null password, we test to see if that authentication works, if not we revert to the inner DataSource's default authentication (i.e. DataSource.getConnection() with no arguments.)

ecbe0fb

Thanks!