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


Java ScriptRunner.setAutoCommit方法代码示例

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


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

示例1: executeSqlScript

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
/**
 * 
 * @param connection
 * @param in
 * @throws Exception
 */
public static void executeSqlScript(Connection connection, InputStream in) throws Exception {
	if (null == connection || null == in) {
		return;
	}
	ScriptRunner runner = new ScriptRunner(connection);
	runner.setAutoCommit(true);
	Reader reader = null;
	try {
		reader = new InputStreamReader(in, "utf-8"); //$NON-NLS-1$
		runner.runScript(reader);
	} catch (Throwable e) {
		throw new Exception("An error occured while try to execute SQL script.", e);
	} finally {
		IOUtils.closeQuietly(reader);
		IOUtils.closeQuietly(in);
		runner.closeConnection();
	}
}
 
开发者ID:primetoninc,项目名称:euler-chidi,代码行数:25,代码来源:DbUtils.java

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

示例3: afterStart

import org.apache.ibatis.jdbc.ScriptRunner; //导入方法依赖的package包/类
@Override
public void afterStart() {
    /*
    测试的数据库(启动后创建)
     */
    Reader config = null;
    Reader sql = null;
    SqlSession sqlSession = null;
    try {
        config = Resources.getResourceAsReader("mybatis-config.xml");
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(config);
        sqlSession = sessionFactory.openSession(true);

        Connection connection = sqlSession.getConnection();
        ScriptRunner runner = new ScriptRunner(connection);
        runner.setAutoCommit(true);

        sql = Resources.getResourceAsReader("easycontroller.sql");
        runner.runScript(sql);

        runner.closeConnection();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(sqlSession);
        IOUtils.closeQuietly(sql);
        IOUtils.closeQuietly(config);
    }
}
 
开发者ID:Xlongshu,项目名称:EasyController,代码行数:30,代码来源:DemoConfig.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.setAutoCommit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。