I have a set of SQL files that transform my original dataset. Currently, I open each file and execute it. How can I execute each file inside a Java program? The goal is to make this process a lot more automatic.
I would like to do something like
Ibatis provides a ScriptRunner that will help you. Simple code snippets you can refer:
Connection conn=getConnection();//some method to get a Connection ScriptRunner runner=new ScriptRunner(conn, false, false); InputStreamReader reader = new InputStreamReader(new FileInputStream("foo.sql")); runner.runScript(reader); reader.close(); conn.close();