Example usage for org.apache.ibatis.logging LogFactory useLog4JLogging

List of usage examples for org.apache.ibatis.logging LogFactory useLog4JLogging

Introduction

In this page you can find the example usage for org.apache.ibatis.logging LogFactory useLog4JLogging.

Prototype

public static synchronized void useLog4JLogging() 

Source Link

Usage

From source file:com.mirth.connect.server.util.SqlConfig.java

License:Open Source License

/**
 * This method loads the MyBatis SQL config file for the database in use,
 * then appends sqlMap entries from any installed plugins
 *///from   w w  w .  ja v  a  2  s. c o  m
public static void init() {
    try {
        LogFactory.useLog4JLogging();
        System.setProperty("derby.stream.error.method", "com.mirth.connect.server.Mirth.getNullOutputStream");

        DatabaseSettings databaseSettings = ControllerFactory.getFactory().createConfigurationController()
                .getDatabaseSettings();

        BufferedReader br = new BufferedReader(Resources.getResourceAsReader("SqlMapConfig.xml"));

        // parse the SqlMapConfig (ignoring the DTD)
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        Document document = factory.newDocumentBuilder().parse(new InputSource(br));

        addPluginSqlMaps(databaseSettings.getDatabase(),
                new DonkeyElement(document.getDocumentElement()).getChildElement("mappers"));

        DocumentSerializer docSerializer = new DocumentSerializer();
        Reader reader = new StringReader(docSerializer.toXML(document));

        sqlSessionfactory = new SqlSessionFactoryBuilder().build(reader, databaseSettings.getProperties());
        sqlSessionManager = SqlSessionManager.newInstance(sqlSessionfactory);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}