Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Sedrick Jefferson
Added: Apr 25, 2018 3:12 PM
Views: 23
SQLite PreparedStatment Delete
  1. String sql = "DELETE FROM Notes WHERE note = ? and  local_date_time = ?";
  2. try (Connection conn = DriverManager.getConnection("jdbc:sqlite:calendarFx.db");
  3.                 PreparedStatement pstmt = conn.prepareStatement(sql))
  4. {
  5.         pstmt.setString(1, note);
  6.         pstmt.setString(2, ldt.toLocalDate().toString());
  7.    
  8.         pstmt.executeUpdate();
  9.        
  10.         Alert alert = new Alert(AlertType.INFORMATION);
  11.         alert.setTitle("Delete Note Dialog");
  12.         alert.setHeaderText("Delete Note");
  13.         alert.setContentText("Note was successfully deleted!");
  14.         alert.show();          
  15. }
  16. catch (SQLException ex)
  17. {
  18.         exceptionDialog(ex.getMessage());
  19. }