0

My program throws an error when I try to execute truncate query using JDBC java with sqlite.

import java.sql.*;
public class sqlTruncate {
    public static void main( String args[] ) {
        try{
            Connection c = null;
            Statement stmt = null;
            Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:Mail.db");
            stmt = c.createStatement();
            String sql = "TRUNCATE TABLE login";
            stmt.executeUpdate(sql);
            c.setAutoCommit(true);
            stmt.close();
            c.close();
        } catch ( Exception e ) {
            System.err.println( e.getClass().getName() + ": " + e.getMessage() );
            System.exit(0);
        }   
    }
}
Roe hit
  • 457
  • 1
  • 7
  • 23
APK3065620
  • 11
  • 1
  • 1
    What's the error you're getting ? Can you please provide more info? – Roe hit Apr 28 '22 at 13:29
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 28 '22 at 15:26

0 Answers0