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


Java ScriptRunner.setErrorLogWriter方法代码示例

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


在下文中一共展示了ScriptRunner.setErrorLogWriter方法的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包/类
@Before
public void setUp() throws Exception {
  Connection conn = null;

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:clmpfx", "sa", "");
    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/column_prefix/CreateDB.sql");
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    conn.commit();
    reader.close();

    reader = Resources.getResourceAsReader(getConfigPath());
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();

  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:26,代码来源:ColumnPrefixTest.java

示例4: initDb

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
private static void initDb(Connection conn) throws IOException, SQLException {
  try {
    Reader scriptReader = Resources
        .getResourceAsReader("org/apache/ibatis/submitted/result_handler_type/CreateDB.sql");
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(scriptReader);
    conn.commit();
    scriptReader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:17,代码来源:DefaultResultHandlerTypeTest.java

示例5: 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/permissions/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/permissions/CreateDB.sql");
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.setErrorLogWriter(null);
  runner.runScript(reader);
  conn.commit();
  conn.close();
  reader.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:20,代码来源:PermissionsTest.java

示例6: openSession

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
public void openSession(String aConfig) throws Exception {

    final String resource = "org/apache/ibatis/submitted/inline_association_with_dot/ibatis-" + aConfig + ".xml";
    Reader batisConfigReader = Resources.getResourceAsReader(resource);

    SqlSessionFactory sqlSessionFactory;
    try {
      sqlSessionFactory = new SqlSessionFactoryBuilder().build(batisConfigReader);
    } catch(Exception anException) {
      throw new RuntimeException("Mapper configuration failed, expected this to work: " + anException.getMessage(), anException);
    }

    SqlSession session = sqlSessionFactory.openSession();

    Connection conn = session.getConnection();
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    Reader createScriptReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/inline_association_with_dot/create.sql");
    runner.runScript(createScriptReader);

    sqlSession = sqlSessionFactory.openSession();
  }
 
开发者ID:txazo,项目名称:mybatis,代码行数:24,代码来源:InlineCollectionWithDotTest.java

示例7: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  Connection conn = null;
  try {
    Reader configReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/dynsql/MapperConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
    configReader.close();
    conn = sqlSessionFactory.getConfiguration().getEnvironment().getDataSource().getConnection();

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

  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:24,代码来源:DynSqlTest.java

示例8: setUp

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  Class.forName("org.hsqldb.jdbcDriver");
  Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:attest", "sa", "");

  Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/awful_table/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/awful_table/MapperConfig.xml");
  sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
  reader.close();
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:19,代码来源:AwfulTableTest.java

示例9: setUp

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

  try {
    Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:mem:gname", "sa", "");
    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/quotedcolumnnames/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/quotedcolumnnames/MapperConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();

  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:26,代码来源:QuotedColumnNamesTest.java

示例10: setUp

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

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

    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/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/multidb/MultiDbConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:27,代码来源:MultiDbTest.java

示例11: initDatabase

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

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

    Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/order_prefix_removed/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/order_prefix_removed/ibatisConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:27,代码来源:OrderPrefixRemoved.java

示例12: runScript

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
public static void runScript(DataSource ds, String resource) throws IOException, SQLException {
    Connection connection = ds.getConnection();
    try {
        ScriptRunner runner = new ScriptRunner(connection);
        runner.setAutoCommit(true);
        runner.setStopOnError(false);
        runner.setLogWriter(null);
        runner.setErrorLogWriter(null);
        runScript(runner, resource);
    } finally {
        connection.close();
    }
}
 
开发者ID:auslides,项目名称:stateless-shiro,代码行数:14,代码来源:DbSetup.java

示例13: initDb

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
private static void initDb(Connection conn) throws IOException, SQLException {
  try {
    Reader scriptReader = Resources.getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/CreateDB.sql");
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(scriptReader);
    conn.commit();
    scriptReader.close();
  } finally {
    if (conn != null) {
      conn.close();
    }
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:16,代码来源:ReverseIncludeTest.java

示例14: initDatabase

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

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

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

    ScriptRunner runner = new ScriptRunner(conn);
    runner.setDelimiter("go");
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    conn.commit();
    reader.close();

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

示例15: runDBScript

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
private static void runDBScript() throws SQLException, IOException {
  Connection conn = sqlSessionFactory.getConfiguration().getEnvironment().getDataSource().getConnection();
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.setErrorLogWriter(null);
  String resource = "org/apache/ibatis/submitted/complex_property/db.sql";
  Reader reader = Resources.getResourceAsReader(resource);
  runner.runScript(reader);
  conn.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:11,代码来源:ComponentTest.java


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