Announcement Announcement Module
Collapse
No announcement yet.
Two Different Databases on two Different Machine Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Two Different Databases on two Different Machine Problem

    Hi All,

    I am new to IBATIS. In one requirement I need to fire a join query on two different databases that are on two different machine having separate username and password. Below is the context file entry for IBATIS.

    Code:
        <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>
              </property> 
              <property name="username"><value>${DATABASE_USERNAME}</value></property>
              <property name="password"><value>${DATABASE_PASSWORD}</value></property>
        </bean> 
    
          <bean id="vfrSqlMap" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
            <property name="dataSource" ref="dataSourceMySQL" />	
    		<property name="configLocation">
                <value>classpath:alfresco/extension/vfr-SqlMap-Config.xml</value>
            </property>
        </bean>
    	
    	<bean id="vfrSqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
            <property name="sqlMapClient" ref="vfrSqlMap"/>
        </bean> 
    
    	<bean id="vfrSupplierDao" class="com.clms.vfr.VFRSupplierDAOImpl">
          <property name="clmsSqlMapClientTemplate" ref="vfrSqlMapClientTemplate"/>
    	</bean>
    The above connection works fine if both the databases are on the same machine and can be accessed with the same username and password. But my problem is, Both the databases are on different-different machine. How can I pass the two connection datasources?

    Please help!
    Thanking you in advance....!

  • #2
    Hello

    But my problem is, Both the databases are on different-different machine. How can I pass the two connection datasources?
    The server where your app is located will call/load/get the two DataBases access for each one through:

    Code:
    <value>jdbc:mysql://${DATABASE_HOST_ADDRESS}:${DATABASE_PORT}/</value>
    The bold part would be a IP address (intranet) or a DNS alias. So, there is no problem.

    If both Database must be in the same Transaction Control you must use JtaTransactionManager

    BTW: org.apache.commons.dbcp.BasicDataSource is not good for production, consider use C3PO.

    HTH

    Comment

    Working...
    X