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

com.ajjpj.asysmon.measure.jdbc.ASysMonDataSource Maven / Gradle / Ivy

package com.ajjpj.asysmon.measure.jdbc;

import com.ajjpj.asysmon.ASysMonApi;

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;

/**
 * @author arno
 */
public class ASysMonDataSource implements DataSource {
    private final DataSource inner;

    private final String poolIdentifier;
    private final ASysMonApi sysMon;

    private final AConnectionCounter counter = AConnectionCounter.INSTANCE; //TODO make this configurable?

    public ASysMonDataSource(DataSource inner, String poolIdentifier, ASysMonApi sysMon) {
        this.inner = inner;
        this.poolIdentifier = poolIdentifier;
        this.sysMon = sysMon;
    }

    @Override public Connection getConnection() throws SQLException {
        return new ASysMonConnection(inner.getConnection(), sysMon, poolIdentifier, counter);
    }

    @Override public Connection getConnection(String username, String password) throws SQLException {
        return new ASysMonConnection(inner.getConnection(username, password), sysMon, poolIdentifier, counter);
    }

    @Override public PrintWriter getLogWriter() throws SQLException {
        return inner.getLogWriter();
    }

    @Override public void setLogWriter(PrintWriter out) throws SQLException {
        inner.setLogWriter(out);
    }

    @Override public void setLoginTimeout(int seconds) throws SQLException {
        inner.setLoginTimeout(seconds);
    }

    @Override public int getLoginTimeout() throws SQLException {
        return inner.getLoginTimeout();
    }

    @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        return inner.getParentLogger();
    }

    @Override public  T unwrap(Class iface) throws SQLException {
        return inner.unwrap(iface);
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy