forked from xerial/sqlite-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressHandler.java
More file actions
41 lines (37 loc) · 1.49 KB
/
Copy pathProgressHandler.java
File metadata and controls
41 lines (37 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.sqlite;
import java.sql.Connection;
import java.sql.SQLException;
/** https://sqlite.org/c3ref/progress_handler.html */
public abstract class ProgressHandler {
/**
* Sets a progress handler for the connection.
*
* @param conn the SQLite connection
* @param vmCalls the approximate number of virtual machine instructions that are evaluated
* between successive invocations of the progressHandler
* @param progressHandler the progressHandler
* @throws SQLException
*/
public static final void setHandler(
Connection conn, int vmCalls, ProgressHandler progressHandler) throws SQLException {
if (conn == null || !(conn instanceof SQLiteConnection)) {
throw new SQLException("connection must be to an SQLite db");
}
if (conn.isClosed()) {
throw new SQLException("connection closed");
}
SQLiteConnection sqliteConnection = (SQLiteConnection) conn;
sqliteConnection.getDatabase().register_progress_handler(vmCalls, progressHandler);
}
/**
* Clears any progress handler registered with the connection.
*
* @param conn the SQLite connection
* @throws SQLException
*/
public static final void clearHandler(Connection conn) throws SQLException {
SQLiteConnection sqliteConnection = (SQLiteConnection) conn;
sqliteConnection.getDatabase().clear_progress_handler();
}
protected abstract int progress() throws SQLException;
}