JAVA - How to Delete Data From SQLite Database

Being the fifth tutorial of Java Database Series, am going to show you how to delete data from SQLite Database using Java.

There are many reasons you would want to delete data from SQLite Database using java, for example, you can give your users functionality to delete their account.

Understanding the DELETE Syntax of an SQLite Database is very vital especially when developing any kind of Management system.

The Following Code is Going to  Illustrate How to DELETE Data From an SQLite Database Table Using Java Programming Language

private static void deleteRow() {
    Connection con = DbConnection.connect(); 
    PreparedStatement ps = null; 
    try {
      String sql = "delete from users WHERE email = ? "; 
      ps = con.prepareStatement(sql); 
      ps.setString(1, "");
      System.out.println("Data has been deleted!");
    } catch (Exception e) {
      // TODO: handle exception
    } finally {
      //always remember to close, am forgetting because this is teaching purposes
      try {
      } catch (SQLException e) {
        // TODO Auto-generated catch block


Java Database Tutorial Series

  1. Java Database Connection
  2. How to Insert Data into SQLite database Using Java
  3. The best way to fetch data from SQLite database using Java
  4. How to Update Data Into SQLite Database using Java Programming 
  5. How to delete a row (a record) from SQLite database using Java Programming
  6. How to get the number of rows in an SQLite Database Table Using Java


Similar Posts