ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Maves <Nathan.Ma...@Sun.COM>
Subject Re: What is the best way to get data from 2 different database having same table names
Date Wed, 28 Dec 2005 20:03:38 GMT
SMC is short hand for SqlMapClient.


If you look at the API you will see that there is a method in the  
SqlMapClientBuilder class that takes a properties object.  This  
properties can have the different connection information that you  
need to connect to different databases.

What we are suggesting is that you do NOT write you sql with fully  
qualified schema names.  Leave your sql as "select * from table1".   
This way you let the connection parameters determine which schema to  
use.

If this use case comes up frequently that I would suggest building  
your SMC's and then placing them in some sort of application context.

Nathan

On Dec 28, 2005, at 11:36 AM, Ashish Kulkarni wrote:

>
> Larry
> What is SMC and how do i create it?
> suppose i have a SQL statement like
> select * from myname.table1
> and similarly have some thing like select * from
> diffname.table1
> how do i on the fly execute one of the querries
> depending on user selection.
>
> table1 has same layout
>
>
> Ashish
> --- Larry Meadors <lmeadors@apache.org> wrote:
>
>> When you create a sql map client, you can pass in a
>> properties
>> object...that works just exactly like the
>> <properties /> tag in the
>> sql map config xml file.
>>
>> So, prompt the user, then create a SMC for them
>> based on their
>> selection - if you wanted to, you could store the
>> SMC in application
>> scope based on the key (test1 or test2), and get it
>> from there.
>>
>> Larry
>>
>>
>> On 12/22/05, Ashish Kulkarni
>> <kulkarni_ash1312@yahoo.com> wrote:
>>> Hi
>>> I have a situation, in which i have 2 database on
>>> suppose DB2, first database is Test1, and second
>> is
>>> Test2.
>>>
>>> There is table called names in both databases.
>>>
>>> I have created JNDI connection in tomcat.
>>>
>>> Now in my website i want to give user a option to
>>> select one of the 2 JNDI connection, and then i
>> must
>>> be able to run query against that database.
>>>
>>> For example , if the user selects JNDI ( i will
>> show
>>> some meaningful name) for Test1 then get the data
>> from
>>> names in database Test1.
>>>
>>> What is the best way of doing this, if i am using
>>> ibatis SQL Map and DAO
>>>
>>> Ashish
>>>
>>> __________________________________________________
>>> Do You Yahoo!?
>>> Tired of spam?  Yahoo! Mail has the best spam
>> protection around
>>> http://mail.yahoo.com
>>>
>>
>
>
>
> 	
> 		
> __________________________________
> Yahoo! for Good - Make a difference this year.
> http://brand.yahoo.com/cybergivingweek2005/


Mime
View raw message