org.jarbframework.utils.DataSourceDelegate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jarb-utils Show documentation
Show all versions of jarb-utils Show documentation
Provides common utilities
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();
}
}