title: Configuring MyBatis with Spring MVC for multiple datasources
body: <p>I have been trying to configure MyBatis with Spring MVC to work with multiple databases. I  have a page which is trying to connect to one of the DB's to fetch data, so that it can be populated into the drop-down boxes.</p>
  
  <p>Now I am not sure what is wrong with this configuration, but I am receiving the following error:</p>
  
  <pre><code>]] Root cause of ServletException. org.springframework.jdbc.BadSqlGrammarException: ### Error querying database.  Cause: java.sql.SQLException: ORA-06576: not a valid function or procedure name
  </code></pre>
  
  <p>I am providing the XML file here for your reference</p>
  
  <pre><code>&lt;bean id="dataSource1"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
          &lt;property name="url" value="jdbc:oracle:thin:@1.1.2.5:1529:DITOS" /&gt;
          &lt;property name="username" value="return" /&gt;
          &lt;property name="password" value="return" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- scan for mappers and let them be autowired --&gt;
      &lt;bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&gt;
          &lt;property name="basePackage"
              value="p.com.ent.appl.return.dev.dao,p.com.ent.appl.return.dep.dao,p.com.ent.appl.return.dao.otheruser" /&gt;
          &lt;property name="sqlSessionFactoryBeanName" value="sqlSessionFactory1" /&gt;
      &lt;/bean&gt;
  
  
      &lt;!-- Declare a transaction manager --&gt;
      &lt;bean id="cashReturnTx"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
          &lt;property name="dataSource" ref="dataSource1" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- define the SqlSessionFactory, notice that configLocation is not needed 
          when you use MapperFactoryBean --&gt;
      &lt;bean id="sqlSessionFactory1" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource1" /&gt;
          &lt;property name="configLocation" value="WEB-INF/mybatis/sqlmap-config.xml" /&gt;
          &lt;!-- &lt;property name="mapperLocations" value="classpath:/com/vrn/ent/dev/daoxml/*.xml" 
              /&gt; --&gt;
          &lt;property name="mapperLocations"
              value="classpath*:/p/com/ent/appl/return/**/daoxml/*.xml" /&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="sqlSession1" class="org.mybatis.spring.SqlSessionTemplate"&gt;
          &lt;constructor-arg index="0" ref="sqlSessionFactory1" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
          &lt;property name="url" value="jdbc:oracle:thin:@4.24.80.15:1522:LM" /&gt;
          &lt;property name="username" value="RETURN" /&gt;
          &lt;property name="password" value="OWNER" /&gt;
      &lt;/bean&gt;
  
  &lt;!-- scan for mappers and let them be autowired --&gt;
      &lt;bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&gt;
          &lt;property name="basePackage"
              value="p.com.ent.appl.return.dev.dao,p.com.ent.appl.return.dep.dao,p.com.ent.appl.return.dao.otheruser" /&gt;
          &lt;property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="otherUserTx"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
  
      &lt;!-- define the SqlSessionFactory, notice that configLocation is not needed 
          when you use MapperFactoryBean --&gt;
      &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="configLocation" value="WEB-INF/mybatis/sqlmap-config.xml" /&gt;
          &lt;!-- &lt;property name="mapperLocations" value="classpath:/com/vrn/ent/dev/daoxml/*.xml" 
              /&gt; --&gt;
          &lt;property name="mapperLocations"
              value="classpath*:/p/com/ent/appl/return/**/daoxml/*.xml" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"&gt;
          &lt;constructor-arg index="0" ref="sqlSessionFactory" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>