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

com.github.davidmoten.rx.jdbc.ConnectionProviderAutoCommitting Maven / Gradle / Ivy

There is a newer version: 0.7.19
Show newest version
package com.github.davidmoten.rx.jdbc;

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

/**
 * Provides {@link Connection}s with autoCommit set to true.
 */
final class ConnectionProviderAutoCommitting implements ConnectionProvider {

    /**
     * Underlying connection provider.
     */
    private final ConnectionProvider cp;

    /**
     * Constructor.
     * 
     * @param cp
     *            underlying connection provider
     */
    ConnectionProviderAutoCommitting(ConnectionProvider cp) {
        this.cp = cp;
    }

    @Override
    public Connection get() {
        Connection con = cp.get();
        try {
            con.setAutoCommit(true);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return con;
    }

    @Override
    public void close() {
        cp.close();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy