io.github.harishb2k.easy.database.mysql.DataSourceProxy Maven / Gradle / Ivy
package io.github.harishb2k.easy.database.mysql;
import javax.inject.Inject;
import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;
public class DataSourceProxy implements DataSource {
private final DataSourceFactory dataSourceFactory;
@Inject
public DataSourceProxy(DataSourceFactory dataSourceFactory) {
this.dataSourceFactory = dataSourceFactory;
}
public DataSource getDataSource() {
return dataSourceFactory.getDataSource();
}
@Override
public Connection getConnection() throws SQLException {
DataSource dataSource = getDataSource();
return dataSource.getConnection();
}
@Override
public Connection getConnection(String username, String password) throws SQLException {
return getDataSource().getConnection(username, password);
}
@Override
public PrintWriter getLogWriter() throws SQLException {
return getDataSource().getLogWriter();
}
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
getDataSource().setLogWriter(out);
}
@Override
public void setLoginTimeout(int seconds) throws SQLException {
getDataSource().setLoginTimeout(seconds);
}
@Override
public int getLoginTimeout() throws SQLException {
return getDataSource().getLoginTimeout();
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return getDataSource().getParentLogger();
}
@Override
public T unwrap(Class iface) throws SQLException {
return getDataSource().unwrap(iface);
}
@Override
public boolean isWrapperFor(Class> iface) throws SQLException {
return getDataSource().isWrapperFor(iface);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy