cignex_india
asked on
Distributed query in MySQL (Two MySQL servers)
In one requirement I need to query two databases that are on different-different machine.
I am using MySQL, Spring and IBATIS.
The below is the spring context file, it is working fine when I put both the databases on same machine.
MySQL Query is:
How can I execute the above query if both the databases (database1 & database2) reside on different-different machine? Will multiple datasources help to solve this problem?
I am using MySQL, Spring and IBATIS.
The below is the spring context file, it is working fine when I put both the databases on same machine.
<bean id="dataSourceMySQL" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://${DATABASE_HOST_ADDRESS}:${DATABASE_PORT}/</value>
<!-- <value>jdbc:mysql://localhost:3306?username=root&password=root</value> -->
</property>
<property name="username"><value>${DATABASE_USERNAME}</value></property>
<property name="password"><value>${DATABASE_PASSWORD}</value></property>
</bean>
<bean id="SqlMap" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSourceMySQL" />
<property name="configLocation">
<value>classpath:alfresco/extension/SqlMap-Config.xml</value>
</property>
</bean>
<bean id="SqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="SqlMap"/>
</bean>
<bean id="SupplierDao" class="com.xyz.abc.SupplierDAOImpl">
<property name="SqlMapClientTemplate" ref="SqlMapClientTemplate"/>
</bean>
MySQL Query is:
SELECT * FROM
database2.table1 a
JOIN database2.table2 b ON a.catid = b.catid
JOIN database1.table3 table3 ON a.name = table3.name WHERE ename = #ename# AND available = 1
GROUP BY titlex
How can I execute the above query if both the databases (database1 & database2) reside on different-different machine? Will multiple datasources help to solve this problem?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.