You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Vinaya Tirikkovalluru <vi...@converge.com> on 2007/10/24 21:39:45 UTC

Calling procedures from 2 different databases

Hi,

 

I am connected to 2 different databases from the application.

 

How would ibatis know which database to go when I try to access a
procedure?

Can I access procedures from 2 databases within the same xml?

 

Thanks in advance

Vinaya 



This electronic message is intended only for the use of the individual(s) or entity(ies) named above and may contain information which is privileged and/or confidential.  If you are not the intended recipient, be aware that any disclosure, copying, distribution, dissemination or use of the contents of this message is prohibited.  If you received this message in error, please notify the sender immediately.

Re: Calling procedures from 2 different databases

Posted by Larry Meadors <lm...@apache.org>.
On 10/24/07, Jeff Butler <je...@gmail.com> wrote:
> One database per SqlmapConfig - that's the rule.
> If you have two databases, then you need two instances of the SqlMapConfig.

Not necessarily - you need two instances of the sql map *client*, but
they can be created by passing different properties to the builder.

This is one of those conversations that may need some clarification:
Does 2 databases mean 2 different Oracle servers, or does it mean an
Oracle server and a M$ SQL Server?

In the either case, as long as the servers are the same structurally,
and dialect differences are masked by stored procedures - it should be
simple.

In the second case, if the databases are not the same
structurally...then Jeff's right. Don't try this. :-)

Larry

Re: Calling procedures from 2 different databases

Posted by Jeff Butler <je...@gmail.com>.
One database per SqlmapConfig - that's the rule.

If you have two databases, then you need two instances of the SqlMapConfig.
IIRC you are using Spring, so...

1. Declare two datasources
2. Declare two SqlMapConfigs - inject a datasource accordingly
3. Inject the appropriate SqlMapConfig into the appropriate DAO.  So, a
particular instance of a DAO is tied to one and only one database.

In general, you should keep the SQL for the different databases in different
XML files - although this is not strictly required.

Jeff Butler


On 10/24/07, Vinaya Tirikkovalluru <vi...@converge.com>
wrote:
>
>   Hi,
>
>
>
> I am connected to 2 different databases from the application.
>
>
>
> How would ibatis know which database to go when I try to access a
> procedure?
>
> Can I access procedures from 2 databases within the same xml?
>
>
>
> Thanks in advance
>
> Vinaya
>
> ------------------------------
> This electronic message is intended only for the use of the individual(s)
> or entity(ies) named above and may contain information which is privileged
> and/or confidential. If you are not the intended recipient, be aware that
> any disclosure, copying, distribution, dissemination or use of the contents
> of this message is prohibited. If you received this message in error, please
> notify the sender immediately.
>
>