Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connection con = GetConnection();
- con.setAutoCommit(false);
- try{
- PreparedStatement ps = con.prepareStatement("INSERT INTO table(col1, col2) VALUES(?, ?)");
- try{
- for(Data d : massagedData){
- ps.setString(1, d.whatever());
- ps.setString(2, d.whatever2());
- ps.addBatch();
- }
- ps.executeBatch();
- }finally{
- ps.close();
- }
- }finally{
- con.close();
- }
- LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
- INSERT INTO (val1, val2) VALUES ('val1;, 'val2');
- INSERT INTO (val1, val2) VALUES ('val3;, 'val4');
- INSERT INTO (val1, val2) VALUES ('val1;, 'val2'), ('val3','val4');
- jdbc:mysql:///<dbname>?rewriteBatchedStatements=true
Add Comment
Please, Sign In to add comment