trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mashengchen <...@git.apache.org>
Subject [GitHub] trafodion pull request #1535: TRAFODION-2957 one stmt support multi-queries
Date Wed, 02 May 2018 05:15:08 GMT
Github user mashengchen commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1535#discussion_r185394999
  
    --- Diff: core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4MultiQueriesPreparedStatement.java
---
    @@ -0,0 +1,372 @@
    +package org.trafodion.jdbc.t4;
    +
    +import java.math.BigDecimal;
    +import java.sql.BatchUpdateException;
    +import java.sql.Date;
    +import java.sql.ResultSet;
    +import java.sql.SQLException;
    +import java.sql.Time;
    +import java.sql.Timestamp;
    +import java.util.logging.Level;
    +
    +public class TrafT4MultiQueriesPreparedStatement extends TrafT4PreparedStatement {
    +
    +    private String[] sqlArr = null;
    +    private TrafT4PreparedStatement[] pstmtArr = null;
    +    private int[][] paramDescs = null;
    +
    +    private int currentSqlIndex;
    +
    +    TrafT4MultiQueriesPreparedStatement(TrafT4Connection connection, String sql) throws
SQLException {
    +        this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
    +                TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT, null);
    +        if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
    +            Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection,
sql);
    +            connection.props_.t4Logger_.logp(Level.FINE, "TrafT4MultiQueriesPreparedStatement",
"<init>", "", p);
    +        }
    +    }
    +
    +    TrafT4MultiQueriesPreparedStatement(TrafT4Connection connection, String sql, String
stmtLabel) throws SQLException {
    +        this(connection, sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
    +                TrafT4ResultSet.CLOSE_CURSORS_AT_COMMIT, stmtLabel);
    +        if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
    +            Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection,
sql, stmtLabel);
    +            connection.props_.t4Logger_.logp(Level.FINE, "TrafT4MultiQueriesPreparedStatement",
"<init>", "", p);
    +        }
    +    }
    +
    +    TrafT4MultiQueriesPreparedStatement(TrafT4Connection connection, String sql, int
resultSetType,
    +            int resultSetConcurrency) throws SQLException {
    +        this(connection, sql, resultSetType, resultSetConcurrency, connection.holdability_,
null);
    +        if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
    +            Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection,
sql, resultSetType,
    +                    resultSetConcurrency);
    +            connection.props_.t4Logger_.logp(Level.FINE, "TrafT4MultiQueriesPreparedStatement",
"<init>", "", p);
    +        }
    +    }
    +
    +    TrafT4MultiQueriesPreparedStatement(TrafT4Connection connection, String sql, int
resultSetType,
    +            int resultSetConcurrency, int resultSetHoldability) throws SQLException {
    +        this(connection, sql, resultSetType, resultSetConcurrency, resultSetHoldability,
null);
    +        if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
    +            Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection,
sql, resultSetType,
    +                    resultSetConcurrency, resultSetHoldability);
    +            connection.props_.t4Logger_.logp(Level.FINE, "TrafT4MultiQueriesPreparedStatement",
"<init>", "", p);
    +        }
    +
    +    }
    +
    +    TrafT4MultiQueriesPreparedStatement(TrafT4Connection connection, String sql, int
resultSetType,
    +            int resultSetConcurrency, int resultSetHoldability, String stmtLabel) throws
SQLException {
    +        super(connection, sql, resultSetType, resultSetConcurrency, resultSetHoldability,
stmtLabel);
    +        if (connection.props_.t4Logger_.isLoggable(Level.FINE) == true) {
    +            Object p[] = T4LoggingUtilities.makeParams(connection.props_, connection,
sql, resultSetType,
    +                    resultSetConcurrency, resultSetHoldability, stmtLabel);
    +            connection.props_.t4Logger_.logp(Level.FINE, "TrafT4MultiQueriesPreparedStatement",
"<init>", "", p);
    +        }
    +
    +        if (resultSetType != ResultSet.TYPE_FORWARD_ONLY && resultSetType !=
ResultSet.TYPE_SCROLL_INSENSITIVE
    +                && resultSetType != ResultSet.TYPE_SCROLL_SENSITIVE) {
    +            throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
    +                    "invalid_resultset_type", null);
    +        }
    +        if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY && resultSetConcurrency
!= ResultSet.CONCUR_UPDATABLE) {
    +            throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
    +                    "invalid_resultset_concurrency", null);
    +        }
    +        if ((resultSetHoldability != 0) && (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
    +                && (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT))
{
    +            throw TrafT4Messages.createSQLException(connection_.props_, connection_.getLocale(),
"invalid_holdability",
    +                    null);
    +        }
    +
    +        sqlArr = sql.split(";");
    --- End diff --
    
    @svarnau @selvaganesang actually, what TrafT4MultiQueriesPreparedStatement do is just
TrafT4PreparedStatement do, so if TrafT4PreparedStatement can avoid insertion attacks or variables
like $PARAM1, then TrafT4MultiQueriesPreparedStatement can


---

Mime
View raw message