当前位置: 首页>>代码示例>>Java>>正文


Java ScriptRunner.setLogWriter方法代码示例

本文整理汇总了Java中org.apache.ibatis.jdbc.ScriptRunner.setLogWriter方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRunner.setLogWriter方法的具体用法?Java ScriptRunner.setLogWriter怎么用?Java ScriptRunner.setLogWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.jdbc.ScriptRunner的用法示例。


在下文中一共展示了ScriptRunner.setLogWriter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearDb

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
/**
 * Clears the db.
 *
 * @param dropTables
 *            if true drop tables, else clean tables
 * @throws SQLException
 */
public void clearDb(DataSource dataSource, boolean dropTables) throws SQLException {
    try (Connection connection = dataSource.getConnection()) {
        ScriptRunner runner = new ScriptRunner(connection);
        LOGGER.debug(connection.getMetaData().toString());

        runner.setStopOnError(false);
        runner.setLogWriter(logWriter);
        runner.setErrorLogWriter(errorLogWriter);
        if (dropTables) {
            runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream(DB_DROP_TABLES_SCRIPT)));
        } else {
            runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream(DB_CLEAR_SCRIPT)));
        }

    } catch (Exception e) {
        LOGGER.error("caught Exception " + e);
    }
    LOGGER.debug(outWriter.toString());
    String errorMsg = errorWriter.toString().trim();

    if (!errorMsg.isEmpty() && errorMsg.indexOf("SQLCODE=-204, SQLSTATE=42704") == -1) {
        LOGGER.error(errorWriter.toString());
    }
}
 
开发者ID:Taskana,项目名称:taskana,代码行数:32,代码来源:DBCleaner.java

示例2: run

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
/**
 * Run all db scripts.
 * @throws SQLException TODO
 */
public void run() throws SQLException {
    Connection connection = dataSource.getConnection();
    ScriptRunner runner = new ScriptRunner(connection);
    LOGGER.debug(connection.getMetaData().toString());

    runner.setStopOnError(true);
    runner.setLogWriter(logWriter);
    runner.setErrorLogWriter(errorLogWriter);

    if (!isSchemaPreexisting(runner)) {
        runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream(DB_SCHEMA)));
    }
    runner.closeConnection();

    LOGGER.debug(outWriter.toString());
    if (!errorWriter.toString().trim().isEmpty()) {
        LOGGER.error(errorWriter.toString());
    }
}
 
开发者ID:Taskana,项目名称:taskana,代码行数:24,代码来源:DbSchemaCreator.java

示例3: setup

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeEach
public void setup() throws Exception {
    Class.forName(JDBC_DRIVER);
    InputStream is = getClass().getResourceAsStream("/examples/joins/CreateJoinDB.sql");
    try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
        ScriptRunner sr = new ScriptRunner(connection);
        sr.setLogWriter(null);
        sr.runScript(new InputStreamReader(is));
    }
    
    UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");
    Environment environment = new Environment("test", new JdbcTransactionFactory(), ds);
    Configuration config = new Configuration(environment);
    config.addMapper(JoinMapper.class);
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(config);
}
 
开发者ID:mybatis,项目名称:mybatis-dynamic-sql,代码行数:17,代码来源:JoinMapperTest.java

示例4: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create an SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/keygen/MapperConfig.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/keygen/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:18,代码来源:Jdbc3KeyGeneratorTest.java

示例5: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create an SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/basetest/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/basetest/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:BaseTest.java

示例6: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create an SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/include_property/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/include_property/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:18,代码来源:IncludePropertyTest.java

示例7: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  Class.forName("org.hsqldb.jdbcDriver");
  Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:annots", "sa", "");
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/substitution_in_annots/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(c);
  runner.setLogWriter(null);
  runner.setErrorLogWriter(null);
  runner.runScript(reader);
  c.commit();
  reader.close();

  Configuration configuration = new Configuration();
  Environment environment = new Environment("test", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:annots", null));
  configuration.setEnvironment(environment);
  
  configuration.addMapper(SubstitutionInAnnotsMapper.class);
  
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:21,代码来源:SubstitutionInAnnotsTest.java

示例8: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/foreach/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/foreach/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:ForEachTest.java

示例9: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/simplelistparameter/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/simplelistparameter/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:SimpleListParameterTest.java

示例10: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/rounding/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/rounding/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:RoundingHandlersTest.java

示例11: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/automapping/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/automapping/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:AutomappingTest.java

示例12: initDatabase

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@Before
public void initDatabase() throws Exception {
  Connection conn = null;

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:force_flush_on_select", "sa", "");

    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/force_flush_on_select/CreateDB.sql");
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    conn.commit();
    reader.close();

    reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/force_flush_on_select/ibatisConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:26,代码来源:ForceFlushOnSelectTest.java

示例13: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  Connection conn = null;

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:batch_keys", "sa", "");

    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/batch_keys/CreateDB.sql");

    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(new PrintWriter(System.err));
    runner.runScript(reader);
    conn.commit();
    reader.close();

    reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/batch_keys/Config.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:27,代码来源:BatchKeysTest.java

示例14: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/cacheorder/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/cacheorder/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:CacheOrderTest.java

示例15: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // create a SqlSessionFactory
  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/cache/mybatis-config.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();

  // populate in-memory database
  SqlSession session = sqlSessionFactory.openSession();
  Connection conn = session.getConnection();
  reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/cache/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.runScript(reader);
  reader.close();
  session.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:CacheTest.java


注:本文中的org.apache.ibatis.jdbc.ScriptRunner.setLogWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。