Guest User

Untitled

a guest
Jan 24th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. INSERT INTO table (col1, col2, col3) VALUES ('val1','val2','val3') ON DUPLICATE KEY UPDATE col1=VALUES(col1),STATUS=1
  2.  
  3. String usersToConvquery = "INSERT INTO ne_ms_conversation_users (conversationId, userId, role) VALUES (?,?,?) ON DUPLICATE KEY UPDATE role=VALUES(role),STATUS=1";
  4. stm = connection.prepareStatement(usersToConvquery);
  5. for (long userId : users) {
  6. stm.setString(1, conversationId);
  7. stm.setLong(2, userId);
  8. stm.setInt(3, 3);
  9. stm.addBatch();
  10. }
  11.  
  12. int[] insertCount = stm.executeBatch();
  13. System.out.println(Arrays.toString(insertCount));
  14.  
  15. INSERT INTO tbl_emp (emp_id,NAME,city,mobileno,salary) VALUES (21,'cccc','ccccc',95959595,5000)
  16. ON DUPLICATE KEY UPDATE salary=VALUES(salary)+1;
Add Comment
Please, Sign In to add comment