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 Ja...@nexweb.org on 2008/01/17 21:48:48 UTC
How to configure Multiple datasource in SqlMapConfig.xml
Hi,
In my project, I have to connect to 2 totally different databases and run
separate queries. How can I define that in SqlMapConfig.xml. The iBATIS
config file does not allow multiple <transactionManager> or <dataSource>
element according to http://ibatis.apache.org/dtd/sql-map-config-2.dtd.
Also what and how would be property name known to iBATIS in that case.
I have my one of the datasource setup like :
<properties resource="ResourceParams.properties"/>
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driverName}"/>
<property name="JDBC.ConnectionURL" value="${rmsJdbcUrl}"/>
<property name="JDBC.Username" value="${rmsUserName}"/>
<property name="JDBC.Password" value="${rmsPassword}"/>
<property name="JDBC.Class"
value="oracle.jdbc.pool.OracleDataSource"/>
<property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
<property name="Pool.TimeToWait" value="500"/>
</dataSource>
</transactionManager>
Where ResourceParams.properties has
driverName=oracle.jdbc.driver.OracleDriver
rmsJdbcUrl=jdbc:oracle:thin:@dbHost_1:dbPort_1:dbSid_1
rmsUserName=username_1
rmsPassword=pwd_1
otmJdbcUrl=jdbc:oracle:thin:@dbHost_2:dbPort_2:dbSid_2
otmdbUserName=username_1
otmdbPassword=pwd_1
How can I configure otmJdbcUrl, otmdbUserName and otmdbPassword.
And there after how to I map <sqlMap> to each of them with separate
resources.
Thanks
Jasmin
******************************************************************************
ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
Our domain name is changing. Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed. Both domains will continue to work, only for a limited
time.
******************************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
******************************************************************************
RE: How to configure Multiple datasource in SqlMapConfig.xml
Posted by Sundar Sankaranarayanan <Su...@phoenix.edu>.
XA transaction or Distributed transactions. If you are using Spring for
integration the you might wanna go through this article
http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html
________________________________
From: Jasmin_Mehta@nexweb.org [mailto:Jasmin_Mehta@nexweb.org]
Sent: Thursday, January 17, 2008 1:57 PM
To: user-java@ibatis.apache.org
Subject: RE: How to configure Multiple datasource in SqlMapConfig.xml
I did not understand when you said handle transactions through XA.
Can you pl be more descriptive?
Thanks
"Sundar Sankaranarayanan" <Su...@phoenix.edu>
01/17/2008 03:55 PM
Please respond to
user-java@ibatis.apache.org
To
<us...@ibatis.apache.org>
cc
Subject
RE: How to configure Multiple datasource in SqlMapConfig.xml
Hi Jasmin,
You might wanna have 2 different sql map files and
handle transactions through XA.
Regards
-S
________________________________
From: Jasmin_Mehta@nexweb.org [mailto:Jasmin_Mehta@nexweb.org]
Sent: Thursday, January 17, 2008 1:49 PM
To: user-java@ibatis.apache.org
Subject: How to configure Multiple datasource in SqlMapConfig.xml
Hi,
In my project, I have to connect to 2 totally different databases and
run separate queries. How can I define that in SqlMapConfig.xml. The
iBATIS config file does not allow multiple <transactionManager> or
<dataSource> element according to
http://ibatis.apache.org/dtd/sql-map-config-2.dtd.
Also what and how would be property name known to iBATIS in that case.
I have my one of the datasource setup like :
<properties resource="ResourceParams.properties"/>
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driverName}"/>
<property name="JDBC.ConnectionURL" value="${rmsJdbcUrl}"/>
<property name="JDBC.Username" value="${rmsUserName}"/>
<property name="JDBC.Password" value="${rmsPassword}"/>
<property name="JDBC.Class"
value="oracle.jdbc.pool.OracleDataSource"/>
<property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
<property name="Pool.TimeToWait" value="500"/>
</dataSource>
</transactionManager>
Where ResourceParams.properties has
driverName=oracle.jdbc.driver.OracleDriver
rmsJdbcUrl=jdbc:oracle:thin:@dbHost_1:dbPort_1:dbSid_1
rmsUserName=username_1
rmsPassword=pwd_1
otmJdbcUrl=jdbc:oracle:thin:@dbHost_2:dbPort_2:dbSid_2
otmdbUserName=username_1
otmdbPassword=pwd_1
How can I configure otmJdbcUrl, otmdbUserName and otmdbPassword.
And there after how to I map <sqlMap> to each of them with separate
resources.
Thanks
Jasmin
************************************************************************
******
ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
Our domain name is changing. Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed. Both domains will continue to work, only for a limited
time.
************************************************************************
******
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
************************************************************************
******
RE: How to configure Multiple datasource in SqlMapConfig.xml
Posted by Ja...@nexweb.org.
I did not understand when you said handle transactions through XA.
Can you pl be more descriptive?
Thanks
"Sundar Sankaranarayanan" <Su...@phoenix.edu>
01/17/2008 03:55 PM
Please respond to
user-java@ibatis.apache.org
To
<us...@ibatis.apache.org>
cc
Subject
RE: How to configure Multiple datasource in SqlMapConfig.xml
Hi Jasmin,
You might wanna have 2 different sql map files and handle
transactions through XA.
Regards
-S
From: Jasmin_Mehta@nexweb.org [mailto:Jasmin_Mehta@nexweb.org]
Sent: Thursday, January 17, 2008 1:49 PM
To: user-java@ibatis.apache.org
Subject: How to configure Multiple datasource in SqlMapConfig.xml
Hi,
In my project, I have to connect to 2 totally different databases and run
separate queries. How can I define that in SqlMapConfig.xml. The iBATIS
config file does not allow multiple <transactionManager> or <dataSource>
element according to http://ibatis.apache.org/dtd/sql-map-config-2.dtd.
Also what and how would be property name known to iBATIS in that case.
I have my one of the datasource setup like :
<properties resource="ResourceParams.properties"/>
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driverName}"/>
<property name="JDBC.ConnectionURL" value="${rmsJdbcUrl}"/>
<property name="JDBC.Username" value="${rmsUserName}"/>
<property name="JDBC.Password" value="${rmsPassword}"/>
<property name="JDBC.Class"
value="oracle.jdbc.pool.OracleDataSource"/>
<property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
<property name="Pool.TimeToWait" value="500"/>
</dataSource>
</transactionManager>
Where ResourceParams.properties has
driverName=oracle.jdbc.driver.OracleDriver
rmsJdbcUrl=jdbc:oracle:thin:@dbHost_1:dbPort_1:dbSid_1
rmsUserName=username_1
rmsPassword=pwd_1
otmJdbcUrl=jdbc:oracle:thin:@dbHost_2:dbPort_2:dbSid_2
otmdbUserName=username_1
otmdbPassword=pwd_1
How can I configure otmJdbcUrl, otmdbUserName and otmdbPassword.
And there after how to I map <sqlMap> to each of them with separate
resources.
Thanks
Jasmin
******************************************************************************
ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
Our domain name is changing. Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed. Both domains will continue to work, only for a limited
time.
******************************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
******************************************************************************
RE: How to configure Multiple datasource in SqlMapConfig.xml
Posted by Sundar Sankaranarayanan <Su...@phoenix.edu>.
Hi Jasmin,
You might wanna have 2 different sql map files and
handle transactions through XA.
Regards
-S
________________________________
From: Jasmin_Mehta@nexweb.org [mailto:Jasmin_Mehta@nexweb.org]
Sent: Thursday, January 17, 2008 1:49 PM
To: user-java@ibatis.apache.org
Subject: How to configure Multiple datasource in SqlMapConfig.xml
Hi,
In my project, I have to connect to 2 totally different databases and
run separate queries. How can I define that in SqlMapConfig.xml. The
iBATIS config file does not allow multiple <transactionManager> or
<dataSource> element according to
http://ibatis.apache.org/dtd/sql-map-config-2.dtd.
Also what and how would be property name known to iBATIS in that case.
I have my one of the datasource setup like :
<properties resource="ResourceParams.properties"/>
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driverName}"/>
<property name="JDBC.ConnectionURL" value="${rmsJdbcUrl}"/>
<property name="JDBC.Username" value="${rmsUserName}"/>
<property name="JDBC.Password" value="${rmsPassword}"/>
<property name="JDBC.Class"
value="oracle.jdbc.pool.OracleDataSource"/>
<property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
<property name="Pool.TimeToWait" value="500"/>
</dataSource>
</transactionManager>
Where ResourceParams.properties has
driverName=oracle.jdbc.driver.OracleDriver
rmsJdbcUrl=jdbc:oracle:thin:@dbHost_1:dbPort_1:dbSid_1
rmsUserName=username_1
rmsPassword=pwd_1
otmJdbcUrl=jdbc:oracle:thin:@dbHost_2:dbPort_2:dbSid_2
otmdbUserName=username_1
otmdbPassword=pwd_1
How can I configure otmJdbcUrl, otmdbUserName and otmdbPassword.
And there after how to I map <sqlMap> to each of them with separate
resources.
Thanks
Jasmin
************************************************************************
******
ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
Our domain name is changing. Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed. Both domains will continue to work, only for a limited
time.
************************************************************************
******
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
************************************************************************
******
Re: How to configure Multiple datasource in SqlMapConfig.xml
Posted by Christopher Lamey <cl...@localmatters.com>.
OK - so you need completely different sqlmaps.
On 1/17/08 2:27 PM, "Jasmin_Mehta@nexweb.org" <Ja...@nexweb.org>
wrote:
> They are completely different schemas and totally different databases - on
> different machines.
>
>
>
>
> Christopher Lamey <cl...@localmatters.com>
> 01/17/2008 04:23 PM
> Please respond to
> user-java@ibatis.apache.org
>
>
> To
> <us...@ibatis.apache.org>
> cc
>
> Subject
> Re: How to configure Multiple datasource in SqlMapConfig.xml
>
>
>
>
>
>
> Are they completely different schemas?
>
> If so, then you'll need two different sqlmaps, DAOs, datasources, etc. A
> single sqlmap generally only talks to one schema.
>
> If they're the same and you can switch based on a runtime parameter, take
> a
> look at this:
>
> http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=
>
> 12583003
>
> Or go with XA.
>
> Cheers,
> topher
>
>
> On 1/17/08 1:48 PM, "Jasmin_Mehta@nexweb.org" <Ja...@nexweb.org>
> wrote:
>
>> Hi,
>>
>> In my project, I have to connect to 2 totally different databases and
> run
>> separate queries. How can I define that in SqlMapConfig.xml. The iBATIS
>> config file does not allow multiple <transactionManager> or <dataSource>
>> element according to http://ibatis.apache.org/dtd/sql-map-config-2.dtd.
>>
>> Also what and how would be property name known to iBATIS in that case.
>>
>> I have my one of the datasource setup like :
>>
>> <properties resource="ResourceParams.properties"/>
>>
>> <transactionManager type="JDBC" commitRequired="false">
>> <dataSource type="SIMPLE">
>> <property name="JDBC.Driver" value="${driverName}"/>
>> <property name="JDBC.ConnectionURL" value="${rmsJdbcUrl}"/>
>> <property name="JDBC.Username" value="${rmsUserName}"/>
>> <property name="JDBC.Password" value="${rmsPassword}"/>
>> <property name="JDBC.Class"
>> value="oracle.jdbc.pool.OracleDataSource"/>
>> <property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
>> <property name="JDBC.DefaultAutoCommit" value="true" />
>> <property name="Pool.MaximumActiveConnections" value="10"/>
>> <property name="Pool.MaximumIdleConnections" value="5"/>
>> <property name="Pool.MaximumCheckoutTime" value="120000"/>
>> <property name="Pool.TimeToWait" value="500"/>
>> </dataSource>
>> </transactionManager>
>>
>>
>> Where ResourceParams.properties has
>>
>> driverName=oracle.jdbc.driver.OracleDriver
>>
>> rmsJdbcUrl=jdbc:oracle:thin:@dbHost_1:dbPort_1:dbSid_1
>> rmsUserName=username_1
>> rmsPassword=pwd_1
>>
>>
>> otmJdbcUrl=jdbc:oracle:thin:@dbHost_2:dbPort_2:dbSid_2
>> otmdbUserName=username_1
>> otmdbPassword=pwd_1
>>
>>
>> How can I configure otmJdbcUrl, otmdbUserName and otmdbPassword.
>>
>> And there after how to I map <sqlMap> to each of them with separate
>> resources.
>>
>> Thanks
>> Jasmin
>>
> ******************************************************************************
>> ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
>> Our domain name is changing. Please take note of the sender's
>> e-Mail address and make changes to your personal address list,
>> if needed. Both domains will continue to work, only for a limited
>> time.
>>
> ******************************************************************************
>> This email and any files transmitted with it are intended solely for
>> the use of the individual or agency to whom they are addressed.
>> If you have received this email in error please notify the Navy
>> Exchange Service Command e-mail administrator. This footnote
>> also confirms that this email message has been scanned for the
>> presence of computer viruses.
>>
>> Thank You!
>>
> ******************************************************************************
>>
>
>
Re: How to configure Multiple datasource in SqlMapConfig.xml
Posted by Ja...@nexweb.org.
They are completely different schemas and totally different databases - on
different machines.
Christopher Lamey <cl...@localmatters.com>
01/17/2008 04:23 PM
Please respond to
user-java@ibatis.apache.org
To
<us...@ibatis.apache.org>
cc
Subject
Re: How to configure Multiple datasource in SqlMapConfig.xml
Are they completely different schemas?
If so, then you'll need two different sqlmaps, DAOs, datasources, etc. A
single sqlmap generally only talks to one schema.
If they're the same and you can switch based on a runtime parameter, take
a
look at this:
http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=
12583003
Or go with XA.
Cheers,
topher
On 1/17/08 1:48 PM, "Jasmin_Mehta@nexweb.org" <Ja...@nexweb.org>
wrote:
> Hi,
>
> In my project, I have to connect to 2 totally different databases and
run
> separate queries. How can I define that in SqlMapConfig.xml. The iBATIS
> config file does not allow multiple <transactionManager> or <dataSource>
> element according to http://ibatis.apache.org/dtd/sql-map-config-2.dtd.
>
> Also what and how would be property name known to iBATIS in that case.
>
> I have my one of the datasource setup like :
>
> <properties resource="ResourceParams.properties"/>
>
> <transactionManager type="JDBC" commitRequired="false">
> <dataSource type="SIMPLE">
> <property name="JDBC.Driver" value="${driverName}"/>
> <property name="JDBC.ConnectionURL" value="${rmsJdbcUrl}"/>
> <property name="JDBC.Username" value="${rmsUserName}"/>
> <property name="JDBC.Password" value="${rmsPassword}"/>
> <property name="JDBC.Class"
> value="oracle.jdbc.pool.OracleDataSource"/>
> <property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
> <property name="JDBC.DefaultAutoCommit" value="true" />
> <property name="Pool.MaximumActiveConnections" value="10"/>
> <property name="Pool.MaximumIdleConnections" value="5"/>
> <property name="Pool.MaximumCheckoutTime" value="120000"/>
> <property name="Pool.TimeToWait" value="500"/>
> </dataSource>
> </transactionManager>
>
>
> Where ResourceParams.properties has
>
> driverName=oracle.jdbc.driver.OracleDriver
>
> rmsJdbcUrl=jdbc:oracle:thin:@dbHost_1:dbPort_1:dbSid_1
> rmsUserName=username_1
> rmsPassword=pwd_1
>
>
> otmJdbcUrl=jdbc:oracle:thin:@dbHost_2:dbPort_2:dbSid_2
> otmdbUserName=username_1
> otmdbPassword=pwd_1
>
>
> How can I configure otmJdbcUrl, otmdbUserName and otmdbPassword.
>
> And there after how to I map <sqlMap> to each of them with separate
> resources.
>
> Thanks
> Jasmin
>
******************************************************************************
> ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
> Our domain name is changing. Please take note of the sender's
> e-Mail address and make changes to your personal address list,
> if needed. Both domains will continue to work, only for a limited
> time.
>
******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
>
> Thank You!
>
******************************************************************************
>
Re: How to configure Multiple datasource in SqlMapConfig.xml
Posted by Christopher Lamey <cl...@localmatters.com>.
Are they completely different schemas?
If so, then you'll need two different sqlmaps, DAOs, datasources, etc. A
single sqlmap generally only talks to one schema.
If they're the same and you can switch based on a runtime parameter, take a
look at this:
http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=
12583003
Or go with XA.
Cheers,
topher
On 1/17/08 1:48 PM, "Jasmin_Mehta@nexweb.org" <Ja...@nexweb.org>
wrote:
> Hi,
>
> In my project, I have to connect to 2 totally different databases and run
> separate queries. How can I define that in SqlMapConfig.xml. The iBATIS
> config file does not allow multiple <transactionManager> or <dataSource>
> element according to http://ibatis.apache.org/dtd/sql-map-config-2.dtd.
>
> Also what and how would be property name known to iBATIS in that case.
>
> I have my one of the datasource setup like :
>
> <properties resource="ResourceParams.properties"/>
>
> <transactionManager type="JDBC" commitRequired="false">
> <dataSource type="SIMPLE">
> <property name="JDBC.Driver" value="${driverName}"/>
> <property name="JDBC.ConnectionURL" value="${rmsJdbcUrl}"/>
> <property name="JDBC.Username" value="${rmsUserName}"/>
> <property name="JDBC.Password" value="${rmsPassword}"/>
> <property name="JDBC.Class"
> value="oracle.jdbc.pool.OracleDataSource"/>
> <property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
> <property name="JDBC.DefaultAutoCommit" value="true" />
> <property name="Pool.MaximumActiveConnections" value="10"/>
> <property name="Pool.MaximumIdleConnections" value="5"/>
> <property name="Pool.MaximumCheckoutTime" value="120000"/>
> <property name="Pool.TimeToWait" value="500"/>
> </dataSource>
> </transactionManager>
>
>
> Where ResourceParams.properties has
>
> driverName=oracle.jdbc.driver.OracleDriver
>
> rmsJdbcUrl=jdbc:oracle:thin:@dbHost_1:dbPort_1:dbSid_1
> rmsUserName=username_1
> rmsPassword=pwd_1
>
>
> otmJdbcUrl=jdbc:oracle:thin:@dbHost_2:dbPort_2:dbSid_2
> otmdbUserName=username_1
> otmdbPassword=pwd_1
>
>
> How can I configure otmJdbcUrl, otmdbUserName and otmdbPassword.
>
> And there after how to I map <sqlMap> to each of them with separate
> resources.
>
> Thanks
> Jasmin
> ******************************************************************************
> ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
> Our domain name is changing. Please take note of the sender's
> e-Mail address and make changes to your personal address list,
> if needed. Both domains will continue to work, only for a limited
> time.
> ******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
>
> Thank You!
> ******************************************************************************
>