Why is JDBC SQLITE TRUNCATE operation throwing an error?

117 views Asked by At

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);
        }   
    }
}
0

There are 0 answers