Java Code Examples for org.apache.ibatis.jdbc.ScriptRunner#setLogWriter()
The following examples show how to use
org.apache.ibatis.jdbc.ScriptRunner#setLogWriter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NpeExtendsTest.java From mybatis with Apache License 2.0 | 6 votes |
@BeforeClass public static void initDatabase() throws Exception { Connection conn = null; try { Class.forName("org.hsqldb.jdbcDriver"); conn = DriverManager.getConnection("jdbc:hsqldb:mem:extends_with_constructor", "sa", ""); Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/extends_with_constructor/CreateDB.sql"); ScriptRunner runner = new ScriptRunner(conn); runner.setLogWriter(null); runner.setErrorLogWriter(null); runner.runScript(reader); conn.commit(); reader.close(); } finally { if (conn != null) { conn.close(); } } }
Example 2
Source File: QuotedColumnNamesTest.java From mybaties with Apache License 2.0 | 6 votes |
@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(); } } }
Example 3
Source File: ForEachTest.java From mybatis with Apache License 2.0 | 6 votes |
@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(); }
Example 4
Source File: CacheTest.java From mybatis with Apache License 2.0 | 6 votes |
@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(); }
Example 5
Source File: AssociationTest.java From mybatis with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { // create a SqlSessionFactory Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/associationtest/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/associationtest/CreateDB.sql"); ScriptRunner runner = new ScriptRunner(conn); runner.setLogWriter(null); runner.runScript(reader); reader.close(); session.close(); }
Example 6
Source File: StringListTest.java From mybaties with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { // create a SqlSessionFactory Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/stringlist/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/stringlist/CreateDB.sql"); ScriptRunner runner = new ScriptRunner(conn); runner.setLogWriter(null); runner.runScript(reader); reader.close(); session.close(); }
Example 7
Source File: ColumnPrefixTest.java From mybaties with Apache License 2.0 | 6 votes |
@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(); } } }
Example 8
Source File: AssociationTest.java From mybaties with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { // create a SqlSessionFactory Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/associationtest/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/associationtest/CreateDB.sql"); ScriptRunner runner = new ScriptRunner(conn); runner.setLogWriter(null); runner.runScript(reader); reader.close(); session.close(); }
Example 9
Source File: DmlMapperReturnTypesTest.java From mybatis with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { // create a SqlSessionFactory Reader reader = Resources.getResourceAsReader(XML); try { sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); } finally { reader.close(); } // populate in-memory database SqlSession session = sqlSessionFactory.openSession(); try { Connection conn = session.getConnection(); reader = Resources.getResourceAsReader(SQL); try { ScriptRunner runner = new ScriptRunner(conn); runner.setLogWriter(null); runner.runScript(reader); } finally { reader.close(); } } finally { session.close(); } }
Example 10
Source File: ForceFlushOnSelectTest.java From mybatis with Apache License 2.0 | 6 votes |
@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(); } } }
Example 11
Source File: BaseTest.java From Mapper with MIT License | 6 votes |
/** * 执行 Sql * * @param reader */ protected void runSql(Reader reader) { if(reader == null){ return; } SqlSession sqlSession = getSqlSession(); try { Connection conn = sqlSession.getConnection(); ScriptRunner runner = new ScriptRunner(conn); runner.setLogWriter(null); runner.runScript(reader); try { reader.close(); } catch (IOException e) {} } finally { sqlSession.close(); } }
Example 12
Source File: AutomaticLazyLoadingTest.java From mybatis with Apache License 2.0 | 6 votes |
/** * Create a session with the specified configuration and initialized the database. */ private void openSession(String aConfig) throws Exception { final String resource = "org/apache/ibatis/submitted/automatic_lazy_loading/ibatis-automatic-lazy-load-" + 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/automatic_lazy_loading/create.sql"); runner.runScript(createScriptReader); sqlSession = sqlSessionFactory.openSession(); }
Example 13
Source File: RoundingHandlersTest.java From mybaties with Apache License 2.0 | 6 votes |
@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(); }
Example 14
Source File: BatchKeysTest.java From mybaties with Apache License 2.0 | 6 votes |
@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(); } } }
Example 15
Source File: AutomappingTest.java From mybaties with Apache License 2.0 | 6 votes |
@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(); }
Example 16
Source File: CriterionTest.java From mybaties with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { Connection conn = null; try { Class.forName("org.hsqldb.jdbcDriver"); conn = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa", ""); Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/criterion/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/criterion/MapperConfig.xml"); sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); reader.close(); } finally { if (conn != null) { conn.close(); } } }
Example 17
Source File: ResultMapExtendsTest.java From mybaties with Apache License 2.0 | 5 votes |
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(); } } }
Example 18
Source File: MultipleReverseIncludeTest.java From mybaties with Apache License 2.0 | 5 votes |
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(); } } }
Example 19
Source File: NotNullColumnTest.java From mybaties with Apache License 2.0 | 5 votes |
@BeforeClass public static void initDatabase() throws Exception { Connection conn = null; try { Class.forName("org.hsqldb.jdbcDriver"); conn = DriverManager.getConnection("jdbc:hsqldb:mem:not_null_column", "sa", ""); Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/not_null_column/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/not_null_column/ibatisConfig.xml"); sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); reader.close(); } finally { if (conn != null) { conn.close(); } } }
Example 20
Source File: BartDBMSUtility.java From BART with MIT License | 4 votes |
private static ScriptRunner getScriptRunner(Connection connection) { ScriptRunner scriptRunner = new ScriptRunner(connection); scriptRunner.setLogWriter(null); // scriptRunner.setErrorLogWriter(null); return scriptRunner; }