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

sqlg3.runtime.DataSourceConnectionManager Maven / Gradle / Ivy

Go to download

SQLG is a preprocessor and a library that uses code generation to simplify writing JDBC code

There is a newer version: 3.1
Show newest version
package sqlg3.runtime;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * Data source implementation of {@link ConnectionManager}. Can be used inside JavaEE containers
 * with container-managed transactions (commit and rollback are not invoked by default, transaction management
 * is relegated to container).
 */
public class DataSourceConnectionManager implements ConnectionManager {

    protected final DataSource dataSource;

    public DataSourceConnectionManager(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public Connection allocConnection() throws SQLException {
        return dataSource.getConnection();
    }

    public void releaseConnection(Connection conn) throws SQLException {
        conn.close();
    }

    /**
     * Does nothing. Override if you do not use container-managed transactions.
     */
    public void commit(Connection conn) throws SQLException {
    }

    /**
     * Does nothing. Override if you do not use container-managed transactions.
     */
    public void rollback(Connection conn) throws SQLException {
    }

    public void close() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy