Results 1 to 2 of 2

Thread: Two Different Databases on two Different Machine Problem

  1. #1
    Join Date
    Jun 2012
    Location
    India
    Posts
    5

    Default 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. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Default

    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
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •