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


Java ScriptRunner.setStopOnError方法代码示例

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


在下文中一共展示了ScriptRunner.setStopOnError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: run

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
private void run() throws IOException, SQLException {
    MysqlDataSource dataSource = new MysqlDataSource();
    dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database);
    dataSource.setUser(username);
    dataSource.setPassword(password);

    try (FileInputStream inputStream = new FileInputStream(file)) {
        ScriptRunner runner = new ScriptRunner(dataSource.getConnection());
        runner.setAutoCommit(true);
        runner.setStopOnError(true);
        runner.runScript(new InputStreamReader(inputStream));
        runner.closeConnection();
    }
}
 
开发者ID:syhily,项目名称:sql-executor,代码行数:15,代码来源:Command.java

示例4: 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

示例5: runReaderScript

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
private static void runReaderScript(Connection conn, SqlSession session, Reader reader) throws Exception {
  ScriptRunner runner = new ScriptRunner(conn);
  runner.setLogWriter(null);
  runner.setSendFullScript(true);
  runner.setAutoCommit(true);
  runner.setStopOnError(false);
  runner.runScript(reader);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:MultipleResultSetTest.java

示例6: 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:yuexiahandao,项目名称:MybatisCode,代码行数:14,代码来源:BaseDataTest.java

示例7: 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(new PrintWriter(System.out));
		runner.setErrorLogWriter(new PrintWriter(System.err));
		runScript(runner, resource);
	} finally {
		connection.close();
	}
}
 
开发者ID:wen866595,项目名称:MyBatis-batch,代码行数:15,代码来源:TestBatchBase.java

示例8: executeSQL

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
private void executeSQL(Connection connection, Reader reader) throws SQLException {
    ScriptRunner runner = new ScriptRunner(connection);
    runner.setAutoCommit(true);
    runner.setStopOnError(true);

    try {
        runner.runScript(reader);
    } catch (RuntimeSqlException e) {
        throw new SQLException(e); // Force to handle the exception by myself
    }
}
 
开发者ID:syhily,项目名称:gossip,代码行数:12,代码来源:GossipDataSourceProvider.java

示例9: loadInitializeData

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@SneakyThrows
private static void loadInitializeData(Injector injector, Reader reader) {
    DataSource dataSource = injector.getInstance(DataSource.class);

    try (final Connection connection = dataSource.getConnection()) {
        ScriptRunner runner = new ScriptRunner(connection);
        runner.setAutoCommit(true);
        runner.setStopOnError(true);
        runner.runScript(reader);
    } // Auto close connection
}
 
开发者ID:syhily,项目名称:gossip,代码行数:12,代码来源:MyBatisTestHelper.java


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