You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Greg Thomas <gr...@gmail.com> on 2011/10/03 15:52:32 UTC

Basic data source; URL not distinguishing between different databases ?

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?

Thanks,

Greg

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


Re: [dbcp] Re: Basic data source; URL not distinguishing between different databases ?

Posted by Greg Thomas <gr...@gmail.com>.
On 3 October 2011 23:37, Phil Steitz <ph...@gmail.com> wrote:
>
> Looks odd.  What you are trying to do should work.

Try as I might, I just can't reproduce it. Not even in the original
application where I thought I first saw the error. I strongly suspect
that this is all caused by a PEBCAK, so sorry for raising it!

Greg

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


Re: [dbcp] Re: Basic data source; URL not distinguishing between different databases ?

Posted by Greg Thomas <gr...@gmail.com>.
On 3 October 2011 23:37, Phil Steitz <ph...@gmail.com> wrote:
> On Mon, Oct 3, 2011 at 6:52 AM, Greg Thomas <gr...@gmail.com> wrote:
>> I'm making fairly simply use of the BasicDataSource, something like ...
...
> 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.

Will do. If I can't create a fairly simple test case, then it's
probably a bug with my code, anyway :)

Greg

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


[dbcp] Re: Basic data source; URL not distinguishing between different databases ?

Posted by Phil Steitz <ph...@gmail.com>.
On Mon, Oct 3, 2011 at 6:52 AM, Greg Thomas <gr...@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