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

org.jarbframework.utils.DataSourceDelegate Maven / Gradle / Ivy

There is a newer version: 2.4.3
Show newest version
package org.jarbframework.utils;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;

import javax.sql.DataSource;

/**
 * Delegate implementation of {@link DataSource}. Delegates all method invocation to
 * a delegate data source instance, modifiable by {@link #setDelegate(DataSource)}.
 * 
 * @author Jeroen van Schagen
 * @since 28-04-2011
 */
public class DataSourceDelegate implements DataSource {
    
    private final DataSource delegate;

    public DataSourceDelegate(DataSource delegate) {
        this.delegate = delegate;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Connection getConnection() throws SQLException {
        return delegate.getConnection();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Connection getConnection(String username, String password) throws SQLException {
        return delegate.getConnection(username, password);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PrintWriter getLogWriter() throws SQLException {
        return delegate.getLogWriter();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int getLoginTimeout() throws SQLException {
        return delegate.getLoginTimeout();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setLogWriter(PrintWriter out) throws SQLException {
        delegate.setLogWriter(out);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setLoginTimeout(int seconds) throws SQLException {
        delegate.setLoginTimeout(seconds);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isWrapperFor(Class type) throws SQLException {
        return delegate.isWrapperFor(type);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public  T unwrap(Class type) throws SQLException {
        return delegate.unwrap(type);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        return delegate.getParentLogger();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy