Required Jar :: mybatis-3.2.3.jar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*It'll be easier using iBatics. | |
http://repo1.maven.org/maven2/org/mybatis/mybatis/3.2.3/mybatis-3.2.3.jar | |
Additionally you need MySQL java driver:com.mysql.jdbc.Driver which can be found in mysql site. */ | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.sql.DriverManager; | |
import org.apache.ibatis.jdbc.ScriptRunner; | |
public class RunMyScript { | |
public static void main(String[] args) { | |
String script = "scriptname.sql"; | |
try { | |
Class.forName("com.mysql.jdbc.Driver"); | |
new ScriptRunner(DriverManager.getConnection( | |
"jdbc:mysql://localhost:3306/mysql", "root", "root`")) | |
.runScript(new BufferedReader(new FileReader(script))); | |
} catch (Exception e) { | |
System.err.println(e); | |
} | |
} | |
} | |
No comments:
Post a Comment