How to get SQLite 'VACUUM' Progress How to get SQLite 'VACUUM' Progress sqlite sqlite

How to get SQLite 'VACUUM' Progress


No.The SQLite C API has a progress handler, but it's probably not exposed by your Java driver, and the vacuum processing is implemented with a different mechanism that does not report the progress anyway.

You could try to look at the current size of the database file and of any temporary files, but it is practically impossible to get the name of the latter.


I found the answer to my question.So i know the size of the actual .db file and i wrote a Service in javaFX which calculates every 50 miliseconds the size of .db-journal file.So i check very frequently the size of journal file to see how of % is builded based on actual .db file:

package windows;import java.io.File;import javafx.concurrent.Service;import javafx.concurrent.Task; /** Get the progress of Vacuum Operation */public class VacuumProgress extends Service<Void> {File basicFile;File journalFile;/** * Starts the Vacuum Progress Service *  * @param basicFile * @param journalFile */public void start(File basicFile, File journalFile) {    this.basicFile = basicFile;    this.journalFile = journalFile;    reset();    start();}@Overrideprotected Task<Void> createTask() {    return new Task<Void>() {        @Override        protected Void call() throws Exception {            System.out.println("Started...");            long bfL = basicFile.length();            while (!journalFile.exists()) {                Thread.sleep(50);                System.out.println("Journal File not yet Created!");            }            long jfL = journalFile.length();            while (jfL <= bfL) {                updateProgress(jfL = journalFile.length(), bfL);                Thread.sleep(50);            }            System.out.println("Exited Vacuum Progress Service");            return null;        }    };}}