You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by SBP <su...@sas.com> on 2006/11/06 10:11:03 UTC
Mutilple data base
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.
regards,
Subi
--
View this message in context: http://www.nabble.com/Mutilple-data-base-tf2581213.html#a7195409
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
Re: Mutilple data base
Posted by Ted Husted <hu...@apache.org>.
On 11/7/06, Ted Husted <hu...@apache.org> wrote:
> 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.
And, voila, there it is:
* http://opensource.atlassian.com/confluence/oss/x/uhc
Thanks Gilles!
-Ted.
Re: Mutilple data base
Posted by Ted Husted <hu...@apache.org>.
On 11/6/06, SBP <su...@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.