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

org.jsimpledb.kv.mysql.MySQLKVTransaction Maven / Gradle / Ivy

There is a newer version: 3.6.1
Show newest version

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

package org.jsimpledb.kv.mysql;

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

import org.jsimpledb.kv.sql.SQLKVDatabase;
import org.jsimpledb.kv.sql.SQLKVTransaction;

/**
 * MySQL variant of {@link SQLKVTransaction}.
 */
class MySQLKVTransaction extends SQLKVTransaction {

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

    @Override
    public void setTimeout(long timeout) {
        super.setTimeout(timeout);
        try (final Statement statement = this.connection.createStatement()) {
            statement.execute("SET innodb_lock_wait_timeout = " + (timeout + 999) / 1000);
        } catch (SQLException e) {
            throw this.handleException(e);
        }
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy