use of org.apache.ibatis.jdbc.ScriptRunner in project mybatis-3 by mybatis.
the class MultipleCrossIncludeTest method initDb.
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();
}
}
}
use of org.apache.ibatis.jdbc.ScriptRunner in project mybatis-3 by mybatis.
the class TypeHandlerTest method setUp.
@Before
public void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandler/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().register(StringTrimmingTypeHandler.class);
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandler/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
use of org.apache.ibatis.jdbc.ScriptRunner in project mybatis-3 by mybatis.
the class TypeHandlerInjectionTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandlerinjection/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().register(handler);
sqlSessionFactory.getConfiguration().addMapper(Mapper.class);
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/typehandlerinjection/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
use of org.apache.ibatis.jdbc.ScriptRunner in project mybatis-3 by mybatis.
the class UseActualParamNameTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
// create an SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/usesjava8/use_actual_param_name/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/usesjava8/use_actual_param_name/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
use of org.apache.ibatis.jdbc.ScriptRunner in project mybatis-3 by mybatis.
the class MultipleIncludeTest method initDb.
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();
}
}
}
Aggregations