Код: Выделить всё
public static void importBD (Connection connection) throws SQLException{
Statement s= connection.createStatement();
s.executeUpdate("USE example");
s.close();
}
public static void importDataBase(Connection connection) throws SQLException, IOException{
BufferedReader bf = new BufferedReader(new FileReader("example.sql"));
Statement s = connection.createStatement();
String line="", db="";
while((line=bf.readLine())!=null){
if(!line.startsWith("--") && !line.equals("")){
db += line;
if(db.contains(";")){
s.execute(db);
db = "";
}
}
}
s.close();
bf.close();
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... using-java