All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.permazen.kv.sqlite.SQLiteKVTransaction Maven / Gradle / Ivy


/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package io.permazen.kv.sqlite;

import io.permazen.kv.sql.SQLKVDatabase;
import io.permazen.kv.sql.SQLKVTransaction;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * SQLite variant of {@link SQLKVTransaction}.
 */
class SQLiteKVTransaction extends SQLKVTransaction {

    SQLiteKVTransaction(SQLKVDatabase database, Connection connection) throws SQLException {
        super(database, connection);
    }

    @Override
    public void setTimeout(long timeout) {
        super.setTimeout(timeout);
        try (Statement statement = this.connection.createStatement()) {
            statement.execute("PRAGMA busy_timeout=" + timeout);
        } catch (SQLException e) {
            throw this.handleException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy