Guest User

Untitled

a guest
Jun 28th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. String[] id = request.getParameterValues("deletechkbox");
  2. int count=0;
  3. Connection conn = null;
  4. try {
  5. Class.forName("com.mysql.jdbc.Driver");
  6. // Step 2: Define Connection URL
  7. String connURL = "jdbc:mysql://localhost/medicloud?user=root&password=root";
  8. // Step 3: Establish connection to URL
  9. conn = DriverManager.getConnection(connURL);
  10.  
  11. if (id != null)
  12. {
  13.  
  14. for(int i=0; i<id.length; i++){
  15.  
  16. String sqlStr = "DELETE from exercise1 where id=?";
  17. PreparedStatement pstmt = conn.prepareStatement(sqlStr);
  18. pstmt.setInt(3, Integer.parseInt(id[i]));
  19. int rec = pstmt.executeUpdate();
  20. if (rec==1)
  21. count++;
  22. }
  23. }
Add Comment
Please, Sign In to add comment