commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Thomas <greg.d.tho...@gmail.com>
Subject Basic data source; URL not distinguishing between different databases ?
Date Mon, 03 Oct 2011 13:52:32 GMT
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


Mime
View raw message