Github user mashengchen commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1535#discussion_r185398464
--- Diff:
core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4MultiQueriesPreparedStatement.java
---
@@ -0,0 +1,393 @@
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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.
+//
+// @@@ END COPYRIGHT @@@
+
+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(";");
+ pstmtArr = new TrafT4PreparedStatement[sqlArr.length];
+ paramDescs = new int[sqlArr.length][3];
+ int total = 0;
+ int currentParamsLen = 0;
+ for (int i = 0; i < sqlArr.length; i++) {
+ pstmtArr[i] = new TrafT4PreparedStatement(connection,
sqlArr[i], resultSetType, resultSetConcurrency,
+ resultSetHoldability, stmtLabel);
+ pstmtArr[i].prepare(sqlArr[i], queryTimeout_,
resultSetHoldability_);
+
+ // this is to setup the paramDescs, each paramDesc has 3
column,
+ // 1: index of preparedStatement
+ // 2: num of params for current pstmt
+ // 3: accumulated params for current index
+ // this varible is used when there invoking setXXX api
+ if (pstmtArr[i].inputDesc_ != null) {
+ currentParamsLen = pstmtArr[i].inputDesc_.length;
+ total += currentParamsLen;
+ }
+ int[] paramDesc = { i, currentParamsLen, total };
+ paramDescs[i] = paramDesc;
+
+ }
+ }
+
+ public boolean execute(String sql) throws SQLException {
--- End diff --
@selvaganesang so your suggestion is to remove the method or throw
exception when user invoke the method?
i see TrafT4PreparedStatement not mark the methods( execute(sql) ) as not
support
---