title: How connect multiply databases ( hsqldb, mysql ) with DB setting in separate files
body: <p>Basically I want to decide with which of 2 databases project will run.</p>
  
  <p>I have following  <strong>hibernateContext.xml</strong></p>
  
  <pre><code>  &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="locations"&gt;
          &lt;list&gt;
              &lt;value&gt;classpath:database.properties&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
   &lt;/bean&gt;
  
  
  &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="${jdbc.driver}" /&gt;
      &lt;property name="url" value="${jdbc.url}" /&gt;
      &lt;property name="username" value="${jdbc.user}" /&gt;
      &lt;property name="password" value="${jdbc.password}" /&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="packagesToScan" value="com.blog.przem.entity" /&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
  
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And <strong>database.properties</strong> file</p>
  
  <pre><code>jdbc.driver=com.mysql.jdbc.Driver
  jdbc.url=jdbc:mysql://localhost:3306/pbdb
  jdbc.user=root
  jdbc.password=
  </code></pre>
  
  <p>What I'm trying to achieve is to add HSQLDB to my project (for development, testing) but for production I want to have MySQL DB. 
  I already seen some solutions:</p>
  
  <p><ul>
  <li>in spring config file <a href="https://stackoverflow.com/questions/14607665/can-i-use-hsqldb-for-junit-testing-cloning-a-mysql-database"><a href="https://stackoverflow.com/questions/14607665/can-i-use-hsqldb-for-junit-testing-cloning-a-mysql-database">Can I use HSQLDB for junit testing cloning a mySQL database</a></a></li>
  <li> in maven <a href="http://www.manydesigns.com/en/portofino/portofino3/tutorials/using-maven-profiles-and-resource-filtering" rel="nofollow noreferrer"><a href="http://www.manydesigns.com/en/portofino/portofino3/tutorials/using-maven-profiles-and-resource-filtering" rel="nofollow noreferrer">http://www.manydesigns.com/en/portofino/portofino3/tutorials/using-maven-profiles-and-resource-filtering</a></a></li>
  </ul>
  I wondering what is best approach, but I would like to keep databases settings in separate files. </p>
  
  <ol>
  <li>Should I create <strong>database.properties2</strong> file (with HSQL properties) and add <strong>propertyConfigurer2</strong>? And how to make dataSource bean to know  which <strong>propertyConfigurer</strong> to use (I have feeling that I miss something)?</li>
  <li>Maybe it should be done by maven?</li>
  <li>What is professional approach to such problem (assuming that project finaly will use MySQL) - application should always use MySQL, and HSQLDB should be used only for running tests classes?</li>
  </ol>