commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject [dbcp] Re: Basic data source; URL not distinguishing between different databases ?
Date Mon, 03 Oct 2011 22:37:05 GMT
On Mon, Oct 3, 2011 at 6:52 AM, Greg Thomas <greg.d.thomas@gmail.com> wrote:
> I'm making fairly simply use of the BasicDataSource, something like ...
>
> BasicDataSource ds1 = new BasicDataSource();
> ds1.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
> ds1.setUrl("jdbc:sqlserver://host\\INST01;databaseName=db1");
>
> and everything works just fine.
>
> Until, that is, I try to access another database on the same server.
> If I have another datasource ...
>
> BasicDataSource ds2 = new BasicDataSource();
> ds2.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
> ds2.setUrl("jdbc:sqlserver://host\\INST01;databaseName=db2");
>
> Then both ds1.getConnection() and ds2.getConnection() will return a
> connection to the same database db1 - unless I call
> ds2.getConnection() first, and they both return a connection to db2.
>
> Have I missed something in the usage of a BasicDataSource? Or is
> something more untoward going on here?

Looks odd.  What you are trying to do should work.  Are you sure the
connections are not getting switched somehow?  Please open a JIRA
ticket if not.  A test case attached to the ticket would be great.

Phil
>
> Thanks,
>
> Greg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Mime
View raw message