Guest User

Untitled

a guest
Jun 4th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Connection con = GetConnection();
  2. con.setAutoCommit(false);
  3. try{
  4. PreparedStatement ps = con.prepareStatement("INSERT INTO table(col1, col2) VALUES(?, ?)");
  5. try{
  6. for(Data d : massagedData){
  7. ps.setString(1, d.whatever());
  8. ps.setString(2, d.whatever2());
  9. ps.addBatch();
  10. }
  11. ps.executeBatch();
  12. }finally{
  13. ps.close();
  14. }
  15. }finally{
  16. con.close();
  17. }
  18.  
  19. LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
  20.  
  21. INSERT INTO (val1, val2) VALUES ('val1;, 'val2');
  22. INSERT INTO (val1, val2) VALUES ('val3;, 'val4');
  23.  
  24. INSERT INTO (val1, val2) VALUES ('val1;, 'val2'), ('val3','val4');
  25.  
  26. jdbc:mysql:///<dbname>?rewriteBatchedStatements=true
Add Comment
Please, Sign In to add comment