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

net.hasor.dbvisitor.AbstractDataSource Maven / Gradle / Ivy

The newest version!
package net.hasor.dbvisitor;
import net.hasor.cobble.logging.Logger;

import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.SQLException;

public abstract class AbstractDataSource implements DataSource {

    /** Logger available to subclasses */
    protected Logger logger = Logger.getLogger(getClass());

    /** Returns 0, indicating the default system timeout is to be used. */
    @Override
    public int getLoginTimeout() throws SQLException {
        return 0;
    }

    /** Setting a login timeout is not supported. */
    @Override
    public void setLoginTimeout(int timeout) throws SQLException {
        throw new UnsupportedOperationException("setLoginTimeout");
    }

    /** LogWriter methods are not supported. */
    @Override
    public PrintWriter getLogWriter() {
        throw new UnsupportedOperationException("getLogWriter");
    }

    /** LogWriter methods are not supported. */
    @Override
    public void setLogWriter(PrintWriter pw) throws SQLException {
        throw new UnsupportedOperationException("setLogWriter");
    }

    //---------------------------------------------------------------------
    // Implementation of JDBC 4.0's Wrapper interface
    //---------------------------------------------------------------------

    @Override
    public  T unwrap(Class iface) throws SQLException {
        if (iface.isInstance(this)) {
            return (T) this;
        }
        throw new SQLException("DataSource of type [" + getClass().getName() + "] cannot be unwrapped as [" + iface.getName() + "]");
    }

    @Override
    public boolean isWrapperFor(Class iface) throws SQLException {
        return iface.isInstance(this);
    }

    //---------------------------------------------------------------------
    // Implementation of JDBC 4.1's getParentLogger method
    //---------------------------------------------------------------------

    @Override
    public java.util.logging.Logger getParentLogger() {
        return java.util.logging.Logger.getLogger(java.util.logging.Logger.GLOBAL_LOGGER_NAME);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy