简体   繁体   中英

how to split sql queries and execute them using java?

I have a files containing sql scripts both DDL and DML scripts like create, insert, update, delete, create views etc.

i need to split them correctly an execute them, any suggestions..

thanks in advance

eventually duplicated question: Split multiple SQL statements into individual SQL statements

To execute you could use something like:

Statement stmt = conn.createStatement();
for(String statement : statements) {
    stmt.addBatch(statement);
}
stmt.executeBatch();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM