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 SqlScript.execute("myScript.sql");
NOTE these SQL scripts act on one database. I assume I would have to pass some kind of connection string. I am using MySQL.
- What objects, libraries, packages, etc… do I need to perform this inside Java?
Ibatis provides a ScriptRunner that will help you. Simple code snippets you can refer: