db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject connectionAttributes overriding DataSource properties??
Date Tue, 05 Jul 2005 19:38:31 GMT
Any thoughts on what the behaviour should be for a Derby data source if
attributes in the connectionAttributes property conflict with other
properties of the data source? E.g. with a Derby datasource I can have

user=fred
connectionAttributes=user=barney

With both embedded and client DataSource implementations a
DataSource.getConnection() request obtains a connection with user name
barney. However there is a bug in ClientDataSource where the first
connection attempt using getConnection() creates a NetConnection object
passing in the user name as fred. On a simple test doesn't seem to cause
any problems but I'm sure there are bugs where part of the system thinks
the user is fred and part barney.

What about DataSource.getConnection("wilma", "password")?
Again with user set in connectionAttributes, the user name becomes
barney. And again in the ClientDataSource case the NetConnection will be
created with the name wilma.

Note user is just an example here, any other data source property that
can also be set as a jdbc attribute has this problem. ClientDataSource
also updates its properties from the connectionAttributes on its first
connection attempt, though not all the properties, only a partial set.
I'm not sure this updating (method updateDataSourceValues) should take
place, it is partially responsible for the bug above.

The DriverManager has the same problem, though in this case it is
limited to user and password, e.g. both of these connect as barney.

DriverManager.getConnection("jdbc:derby:wombat;user=barney", "wilma",
"pwd"));

p.put("user", "fred");
testDS(DriverManager.getConnection("jdbc:derby:wombat;user=barney", p));

For the DriveManager case, this page does state that the attributes
provided in the embedded URL will be added to the set passed to the
getConnection call. This could imply that the ones on the URL override
those in the set, would be nice to state here what is meant to happen if
the property exists in both places.

http://incubator.apache.org/derby/docs/ref/rrefjdbc10889.html#rrefjdbc10889

The DriverManager/Driver classes enforce that the user and password
passed in explicitly (DriverManager.getConnection(user,password) and
passed into Derby as 'user' and 'password' properties in a properties
object. Thus Derby can not determine if the user was supplied explicitly
or by a properties object.


To my mind, with a DataSource connectionAttributes should only be used
for cases where the attribute can not be set as a property, thus their
value should be ignored or overridden by any explict setting.


Dan.



Mime
View raw message