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

com.codingapi.springboot.permission.jdbc.StatementProxy Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.codingapi.springboot.permission.jdbc;

import com.codingapi.springboot.framework.event.EventPusher;
import com.codingapi.springboot.permission.analyzer.SQL;
import com.codingapi.springboot.permission.event.JdbcStatementExecuteEvent;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class StatementProxy extends BaseStatement implements Statement {

    private final Statement delegate;

    public StatementProxy(Statement delegate) {
        super(delegate);
        this.delegate = delegate;
    }

    @Override
    public ResultSet executeQuery(String sql) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.executeQuery(executeSql.getSql());
    }

    @Override
    public int executeUpdate(String sql) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.executeUpdate(executeSql.getSql());
    }

    @Override
    public boolean execute(String sql) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.execute(executeSql.getSql());
    }

    @Override
    public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.executeUpdate(executeSql.getSql(), autoGeneratedKeys);
    }

    @Override
    public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.executeUpdate(executeSql.getSql(), columnIndexes);
    }

    @Override
    public int executeUpdate(String sql, String[] columnNames) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.executeUpdate(executeSql.getSql(), columnNames);
    }

    @Override
    public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.execute(executeSql.getSql(), autoGeneratedKeys);
    }

    @Override
    public boolean execute(String sql, int[] columnIndexes) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.execute(executeSql.getSql(), columnIndexes);
    }

    @Override
    public boolean execute(String sql, String[] columnNames) throws SQLException {
        SQL executeSql = new SQL(sql);
        EventPusher.push(new JdbcStatementExecuteEvent(delegate,executeSql));
        return delegate.execute(executeSql.getSql(), columnNames);
    }

    @Override
    public ResultSet getResultSet() throws SQLException {
        return delegate.getResultSet();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy