ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Husted" <hus...@apache.org>
Subject Re: Mutilple data base
Date Tue, 07 Nov 2006 17:32:07 GMT
On 11/6/06, SBP <subhash.bp@sas.com> wrote:
>
> Hi all,
>       In ibatis I have 2 databases DB1 and DB2 both in MYSQL.
>
>  In the config.xml I have given the database name as DB1 for connection, and
> in one of the select query I have given : "select * from DB2.tablename". It
> is working. How ?
>
> In this case no need maintain multiple config files ?
>
> Please explain.

If you have a query browser for your database, try doing the same
thing outside of iBATIS. First "USE DB1" and then execute a query
using the database.table syntax. I expect that it will work there too.
(It works for me with MySQL). But, I expect that it would only work
when the credentials for the databases are the same, and you are
working on two databases on the same server.

I'm actually working on similar use case myself. We know have a
separate database setup for running tests that we can recreate on
demand. Right now, we swtich between the testing database and
production database by changing the connection string in the iBATIS
configuration so that it references the test database. We use
properties for the strings (${testing} versus ${production}), so that
works fairly well.

But, what I would really like to do is be able to switch datasources
at runtime from within the application, so that we could have a
production database, and training database, and testing database, and
let users switch between these.

-Ted.






-Ted.





iBATIS is just sending the SQL to the database.

Mime
View raw message