title: iBatis - select environment using XML
body: <p>I have this configuration in <code>ibatis-config.xml</code></p>
  
  <pre><code>&lt;configuration&gt;
      &lt;properties resource="collector.properties"/&gt;
      &lt;environments default="development"&gt;
          &lt;environment id="development"&gt;
              &lt;transactionManager type="JDBC" /&gt;
              &lt;dataSource type="POOLED"&gt;
                  &lt;property name="driver" value="${dev.jdbc.driver}" /&gt;
                  &lt;property name="url" value="${dev.jdbc.url}" /&gt;
              &lt;/dataSource&gt;
          &lt;/environment&gt;
          &lt;environment id="test"&gt;
              &lt;transactionManager type="JDBC" /&gt;
              &lt;dataSource type="POOLED"&gt;
                  &lt;property name="driver" value="${test.jdbc.driver}" /&gt;
                  &lt;property name="url" value="${test.jdbc.url}" /&gt;
              &lt;/dataSource&gt;
          &lt;/environment&gt;
      &lt;/environments&gt;
      &lt;mappers&gt;
      &lt;/mappers&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>As shown it will load datasource from <code>&lt;environment id="development"&gt;</code></p>
  
  <p><b>QUESTION</b>: Is it possible at run time switch to use <code>&lt;environment id="test"&gt;</code> without modifying XML? For example - I have a test file where I'm using <code>SqlSessionFactory</code> and want to set it programmatically to use test environment?</p>