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

com.dattack.jtoolbox.jdbc.internal.AbstractProxyConnection Maven / Gradle / Ivy

There is a newer version: 0.7
Show newest version
/*
 * Copyright (c) 2022, The Dattack team (http://www.dattack.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.dattack.jtoolbox.jdbc.internal;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * {@link ProxyConnection} generic implementation for an underlying connection.
 *
 * @author cvarela
 * @see com.dattack.jtoolbox.jdbc.internal.oracle.OracleProxyConnection
 * @since 0.6
 */
@SuppressWarnings("PMD.TooManyMethods")
public abstract class AbstractProxyConnection implements ProxyConnection {

    private final Connection delegate;

    protected AbstractProxyConnection(final Connection delegate) {
        this.delegate = delegate;
    }

    protected abstract Statement doCreateStatement(final Statement statement);

    protected abstract CallableStatement doPrepareCall(final CallableStatement callableStatement);

    protected abstract PreparedStatement doPrepareStatement(final PreparedStatement preparedStatement);

    @Override
    public Statement createStatement() throws SQLException {
        return doCreateStatement(getDelegate().createStatement());
    }

    @Override
    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
        return doCreateStatement(getDelegate().createStatement(resultSetType, resultSetConcurrency));
    }

    @Override
    public Statement createStatement(int resultSetType, int resultSetConcurrency,
            int resultSetHoldability) throws SQLException {
        return doCreateStatement(
                getDelegate().createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
    }

    @Override
    public final Connection getDelegate() {
        return delegate;
    }

    @Override
    public CallableStatement prepareCall(String sql) throws SQLException {
        return doPrepareCall(getDelegate().prepareCall(sql));
    }

    @Override
    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
        return doPrepareCall(getDelegate().prepareCall(sql, resultSetType, resultSetConcurrency));
    }

    @Override
    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
            int resultSetHoldability) throws SQLException {
        return doPrepareCall(getDelegate().prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
    }

    @Override
    public PreparedStatement prepareStatement(String sql) throws SQLException {
        return doPrepareStatement(getDelegate().prepareStatement(sql));
    }

    @Override
    public PreparedStatement prepareStatement(String sql, int resultSetType,
            int resultSetConcurrency) throws SQLException {
        return doPrepareStatement(getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency));
    }

    @Override
    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
            int resultSetHoldability) throws SQLException {
        return doPrepareStatement(
                getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
    }

    @Override
    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
        return doPrepareStatement(getDelegate().prepareStatement(sql, autoGeneratedKeys));
    }

    @Override
    public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
        return doPrepareStatement(getDelegate().prepareStatement(sql, columnIndexes));
    }

    @Override
    public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
        return doPrepareStatement(getDelegate().prepareStatement(sql, columnNames));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy