Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 748143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:17:10+00:00 2026-05-14T14:17:10+00:00

I have this configuration in ibatis-config.xml <configuration> <properties resource=collector.properties/> <environments default=development> <environment id=development> <transactionManager

  • 0

I have this configuration in ibatis-config.xml

<configuration>
    <properties resource="collector.properties"/>
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC" />
            <dataSource type="POOLED">
                <property name="driver" value="${dev.jdbc.driver}" />
                <property name="url" value="${dev.jdbc.url}" />
            </dataSource>
        </environment>
        <environment id="test">
            <transactionManager type="JDBC" />
            <dataSource type="POOLED">
                <property name="driver" value="${test.jdbc.driver}" />
                <property name="url" value="${test.jdbc.url}" />
            </dataSource>
        </environment>
    </environments>
    <mappers>
    </mappers>
</configuration>

As shown it will load datasource from <environment id="development">

QUESTION: Is it possible at run time switch to use <environment id="test"> without modifying XML? For example – I have a test file where I’m using SqlSessionFactory and want to set it programmatically to use test environment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:17:11+00:00Added an answer on May 14, 2026 at 2:17 pm

    SqlSessionFactoryBuilder.build() method can select a specific environment in XML.

    For example,

    private Reader reader;
    private SqlSessionFactory sqlSessionFactorys;
    private SqlSession session;
    
    reader = Resources.getResourceAsReader("ibatis-config.xml");
    
    sqlSessionFactorys = new SqlSessionFactoryBuilder().build(reader, "test");
    testSession = sqlSessionFactorys.openSession(); // test env
    
    sqlSessionFactorys = new SqlSessionFactoryBuilder().build(reader, "development");
    devSession = sqlSessionFactorys.openSession(); // dev env
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this configuration in struts.xml <action name=updateAction class=it.myApp.action.ajax.UpdateActionAction> <result name=success type=json/> <result name=error
Hey I have this configuration in my web.config <log4net> <appender name=LogFileAppender type=log4net.Appender.FileAppender> <param name=File
I have got this code for detection of mobile device. <?xml version=1.0 encoding=UTF-8?> <configuration>
well i have a configuration like this in the components part of my config
I have the layout of a configuration dialog in an XML like this: <?xml
I have this log4j configuration in my grails config.groovy log4j = { error 'org.codehaus.groovy.grails.web.servlet',
I have this configuration in my web.config. <siteMap defaultProvider=Provider1 enabled=true> <providers> <add name=Provider1 siteMapFile=Web.sitemap
At the moment I have this configuration: build.xml: <!-- Ivy settings start--> <condition property=ivy.home
I have this configuration: A page containing a search field, at the submit in
I have this configuration of nginx : server { listen 80; server_name example.com www.example.com;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.