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

com.github.davidmoten.rx.jdbc.ConnectionProviderFromDataSource 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;

import javax.sql.DataSource;

import com.github.davidmoten.rx.jdbc.exceptions.SQLRuntimeException;

/**
 * Provides database connections from a {@link DataSource}.
 */
public class ConnectionProviderFromDataSource implements ConnectionProvider {

    private final DataSource dataSource;

    /**
     * Constructor.
     * 
     * @param dataSource
     *            database connection source
     */
    public ConnectionProviderFromDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public Connection get() {
        try {
            return dataSource.getConnection();
        } catch (SQLException e) {
            throw new SQLRuntimeException(e);
        }
    }

    @Override
    public void close() {
        // do nothing
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy