3

Is there a way to get the progress of sqlite 'VACUUM'?I am using this line of code here in Java:

connection1.createStatement().executeUpdate("VACUUM");

The User(MySelf & I) has to wait from some seconds to some minutes,i know that the actual .db file is being overriten with the help of a journal file that is created through the execution of the command.

Can i get an estimation using JAVA IO or something?Thanks for help..

GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93

2 Answers2

1

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.

CL.
  • 173,858
  • 17
  • 217
  • 259
1

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

@Override
protected 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;
        }

    };
}

}
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93