trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [36/44] incubator-trafodion git commit: Refact package name
Date Tue, 18 Apr 2017 23:52:56 GMT
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/51a83dc2/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java
new file mode 100644
index 0000000..0f0835d
--- /dev/null
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java
@@ -0,0 +1,3509 @@
+// @@@ 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 @@@
+
+/* -*-java-*-
+ * Filename	: SQLMXConnection.java
+ * Description :
+ */
+package org.apache.trafodion.jdbc.t2;
+
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale; // JDK 1.2
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Executor;
+
+import javax.sql.PooledConnection;
+//import com.tandem.tmf.Current;		// Linux port - ToDo
+//import com.tandem.util.FSException;	// Linux port - ToDo
+
+public class SQLMXConnection extends PreparedStatementManager implements
+java.sql.Connection {
+
+private static final short TYPE_UNKNOWN = 0;
+private static final short TYPE_SELECT = 0x0001;
+private static final short TYPE_UPDATE = 0x0002;
+private static final short TYPE_DELETE = 0x0004;
+private static final short TYPE_INSERT = 0x0008;
+private static final short TYPE_INSERT_PARAM = 0x0120; //Modified for CQDs filter from 0x0100 to 0x0120
+private static final short TYPE_EXPLAIN = 0x0010;
+private static final short TYPE_CREATE = 0x0020;
+private static final short TYPE_GRANT = 0x0040;
+private static final short TYPE_DROP = 0x0080;
+private static final short TYPE_CALL = 0x0800;
+    static final short TYPE_CONTROL = 0x0900;
+
+private static CallableStatement createExternalCallableStatement(
+            String className, String call) throws SQLException {
+        Class classX = null;
+
+        /*
+         * Check if the Class exists in the Class path.
+         */
+        try {
+            classX = Class.forName(className);
+        } catch (ClassNotFoundException e) {
+            throw new SQLException("Specified Class not found: "
+                    + e.getLocalizedMessage());
+        }
+
+        /*
+         * Check if the Class implements the CallableStatement interface.
+         */
+        boolean blnIsCallableStatement = false;
+
+        if (classX != null) {
+            Class[] interfaces = classX.getInterfaces();
+            for (int nfor = 0; nfor < interfaces.length; ++nfor) {
+                if (interfaces[nfor].getName().equals(
+                                CallableStatement.class.getName())) {
+                    blnIsCallableStatement = true;
+                    break;
+                }
+            }
+        }
+        if (!blnIsCallableStatement) {
+            throw new SQLException(
+                    "The Specified Class does not implement java.sql.CallableStatement interface.");
+        }
+
+        Constructor[] array = null;
+
+        if (classX != null) {
+            array = classX.getDeclaredConstructors();
+        }
+
+        if (array != null) {
+
+            boolean blnPublic = false;
+
+            for (int nfor = 0; nfor < array.length; ++nfor) {
+                if (array[nfor].getModifiers() == Modifier.PUBLIC) {
+                    blnPublic = true;
+                    Class[] params = array[nfor].getParameterTypes();
+                    if (params != null) {
+                        if (params.length == 1) {
+                            if (params[0].getName().equals(
+                                            String.class.getName())) {
+                                Object initVar[] = new Object[1];
+                                initVar[0] = call;
+                                Object o = null;
+                                try {
+                                    o = array[nfor].newInstance(initVar);
+                                } catch (IllegalArgumentException e) {
+                                    throw new SQLException(e.getMessage());
+                                } catch (InstantiationException e) {
+                                    throw new SQLException(e.getMessage());
+                                } catch (IllegalAccessException e) {
+                                    throw new SQLException(e.getMessage());
+                                } catch (InvocationTargetException e) {
+                                    throw new SQLException(e.getMessage());
+                                }
+                                return (CallableStatement) o;
+                            }
+                        }
+                    }
+                }
+            }
+            if (!blnPublic) {
+                throw new SQLException(
+                        "No Public Constructors available in the Specified Class.");
+            }
+        } else {
+            throw new SQLException(
+                    "No Constructors available in the Specified Class.");
+        }
+        throw new SQLException(
+                "No Constructor available accepting ONLY java.lang.String parameter in the Specified Class.");
+    }
+
+    // java.sql.Connection interface methods
+public void close() throws SQLException {
+        if (this.getTracer() != null)
+        this.getTracer().println(getTraceId() + "close()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_close_V].methodEntry(JdbcDebug.debugLevelPooling);
+        try {
+            // if it is a pooledConnection, don't do hardClose (Close SQL/MX
+            // Resources)
+            if (pc_ != null)
+            close(false, true);
+            else
+            close(true, true);
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_close_V].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization commit() is now synchronized
+     */
+public synchronized void commit() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "commit()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_commit].methodEntry();
+        try {
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            if (autoCommit_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_commit_mode", null);
+            if (beginTransFlag_) {
+                /*
+                 * Transaction was started using Connection.begintransaction()
+                 * API, set the autoCommit_ flag to true.
+                 */
+                autoCommit_ = true;
+                beginTransFlag_ = false;
+            }
+            Statement cs = null;
+            try {
+                // commit the Transaction
+                cs = this.createStatement();
+                cs.execute("commit");
+            } catch (SQLException se) {
+                if (se.getErrorCode() != -8605)
+                throw se;
+            }finally {
+                setTxid_(0);
+                if(cs != null ) {
+                    try {cs.close();} catch(Exception ce) {}
+                }
+            }
+        }finally {
+            if (JdbcDebugCfg.traceActive)
+            debug[methodId_commit].traceOut(JdbcDebug.debugLevelEntry,
+                    "beginTransFlag_ = " + beginTransFlag_
+                    + "; autoCommit_ = " + autoCommit_
+                    + "; txid_ = " + getTxid_());
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_commit].methodExit();
+        }
+    }
+
+public Statement createStatement() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "createStatement()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_createStatement].methodEntry();
+        try {
+            SQLMXStatement stmt = null;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            stmt = new SQLMXStatement(this);
+            if (out_ != null)
+            out_.println(getTraceId() + "createStatement() returns Statement ["
+                    + stmt.getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_createStatement].methodExit();
+        }
+    }
+
+public Statement createStatement(int resultSetType, int resultSetConcurrency)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "createStatement(" + resultSetType + ","
+                + resultSetConcurrency + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_createStatement_II].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_createStatement_II]
+        .methodParameters("resultSetType=" + resultSetType
+                + ", resultSetConcurrency=" + resultSetConcurrency);
+        try {
+            SQLMXStatement stmt = null;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            stmt = new SQLMXStatement(this, resultSetType, resultSetConcurrency);
+            if (out_ != null)
+            out_.println(getTraceId() + "createStatement(" + resultSetType + ","
+                    + resultSetConcurrency + ") returns Statement ["
+                    + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_createStatement_II].methodExit();
+        }
+    }
+
+public Statement createStatement(int resultSetType,
+            int resultSetConcurrency, int resultSetHoldability)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "createStatement(" + resultSetType + ","
+                + resultSetConcurrency + "," + resultSetHoldability + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_createStatement_III].methodEntry();
+        try {
+            SQLMXStatement stmt = null;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            stmt = new SQLMXStatement(this, resultSetType,
+                    resultSetConcurrency, resultSetHoldability);
+            if (out_ != null)
+            out_.println(getTraceId() + "createStatement(" + resultSetType + ","
+                    + resultSetConcurrency + "," + resultSetHoldability
+                    + ") returns Statement ["
+                    + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_createStatement_III].methodExit();
+        }
+    }
+
+public boolean getAutoCommit() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "getAutoCommit()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_getAutoCommit].methodEntry();
+        try {
+            clearWarnings();
+            return autoCommit_;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_getAutoCommit].methodExit();
+        }
+    }
+
+public String getCatalog() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "getCatalog()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_getCatalog].methodEntry();
+        try {
+            clearWarnings();
+            Statement s = null;
+            ResultSet rs = null;
+            String catalog = null;
+            
+            try {
+                s = this.createStatement();
+                rs = s.executeQuery("SHOWCONTROL DEFAULT CATALOG, match full, no header");
+                rs.next();
+                catalog = rs.getString(1);
+                catalog = catalog.substring(catalog.indexOf('.') + 1);
+            } catch (SQLException e) {
+                return this.t2props.getCatalog();
+            } finally {
+                if (rs != null)
+                    rs.close();
+                if (s != null)
+                    s.close();
+            }
+            return catalog;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_getCatalog].methodExit();
+        }
+    }
+
+public int getHoldability() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "getCatalog()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_getHoldability].methodEntry();
+        try {
+            clearWarnings();
+            return holdability_;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_getHoldability].methodExit();
+        }
+    }
+
+public DatabaseMetaData getMetaData() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "getMetaData()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_getMetaData].methodEntry();
+        try {
+            SQLMXDatabaseMetaData metaData;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            metaData = new SQLMXDatabaseMetaData(this);
+            if (out_ != null)
+            out_.println(getTraceId() + "getMetaData() returns DatabaseMetaData ["
+                    + System.identityHashCode(metaData) + "]");
+            if(out_ != null) {
+                return new TDatabaseMetaData(metaData, new TConnection(this, out_), out_);
+            }
+            return metaData;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_getMetaData].methodExit();
+        }
+    }
+
+public int getTransactionIsolation() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "getTransactionIsolation()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_getTransactionIsolation].methodEntry();
+        try {
+            clearWarnings();
+            return transactionIsolation_;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_getTransactionIsolation].methodExit();
+        }
+    }
+
+    // JDK 1.2
+public java.util.Map<String, Class<?>> getTypeMap() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "getTypeMap()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_getTypeMap].methodEntry();
+        try {
+            clearWarnings();
+            return userMap_;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_getTypeMap].methodExit();
+        }
+    }
+
+public boolean isClosed() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "isClosed()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_isClosed].methodEntry();
+        try {
+            clearWarnings();
+            return isClosed_;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_isClosed].methodExit();
+        }
+    }
+
+public boolean isReadOnly() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "isReadOnly()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_isReadOnly].methodEntry();
+        try {
+            clearWarnings();
+            return isReadOnly_;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_isReadOnly].methodExit();
+        }
+    }
+
+public String nativeSQL(String sql) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "nativeSQL(\"" + sql + "\")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_nativeSQL].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_nativeSQL].methodParameters("sql=" + sql);
+        try {
+            clearWarnings();
+            return sql;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_nativeSQL].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization prepareCall() is now synchronized
+     */
+public synchronized CallableStatement prepareCall(String sql)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareCall(\"" + sql + "\")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareCall_L].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareCall_L].methodParameters("sql=" + sql);
+        try {
+
+            if (!this.t2props.getExternalCallHandler().equals("NONE")) {
+                String sqlX = sql;
+                // Set the prefix:
+                String prefix = "EXT";
+                String callHandler = "NONE";
+
+                if (!this.t2props.getExternalCallHandler().equals("NONE")) {
+//					callHandler = SQLMXDataSource.externalCallHandler;
+                    callHandler = this.t2props.getExternalCallHandler();
+                }
+
+                if (!this.t2props.getExternalCallPrefix().equalsIgnoreCase("EXT")) {
+                    prefix = this.t2props.getExternalCallPrefix();
+                }
+
+                if (sqlX.trim().startsWith("{")) {
+                    sqlX = sqlX.trim().substring(1).trim();
+                    if (sqlX.toUpperCase().startsWith(prefix.toUpperCase())) {
+                        CallableStatement externalCallStmt = SQLMXConnection
+                        .createExternalCallableStatement(callHandler,
+                                sql);
+                        return externalCallStmt;
+                    }
+                }
+            }
+            SQLMXCallableStatement cstmt;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            gcStmts();
+            if (isStatementCachingEnabled()) {
+                cstmt = (SQLMXCallableStatement) getPreparedStatement(this,
+                        sql.trim(), ResultSet.TYPE_FORWARD_ONLY,
+                        ResultSet.CONCUR_READ_ONLY, holdability_);
+                if (cstmt != null) {
+                    if (out_ != null) {
+                        out_.println(getTraceId() + "prepareCall(\"" + sql
+                                + "\") returns CallableStatement ["
+                                + cstmt.getStmtLabel_() + "]");
+                        if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                            out_.println(getTraceId() + "prepareStatement(String,resultSetType,resultSetConcurrency,resultSetHoldability) "
+                                    + cstmt.stmtId_+"\"+ GOT STMT FROM CACHE ");
+                        }
+                    }
+
+                    if(out_ != null) {
+                        return new TCallableStatement(cstmt, out_);
+                    }
+                    return cstmt;
+                }
+            }
+            cstmt = new SQLMXCallableStatement(this, sql);
+
+            pStmtCount++;
+            if (out_ != null) {
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() + "prepareCall(String) "
+                            + "PREPARED STMT - " + "\""
+                            + cstmt.stmtId_ + "\"");
+                    out_.println(getTraceId() + "prepareCall(String) "
+                            + "\""+"PREPARED STMT COUNT:"+this.pStmtCount
+                            + "\"");
+                }
+            }
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(cstmt);
+            cstmt.prepareCall(server_, getDialogueId_(), getTxid_(),
+                    autoCommit_, transactionMode_, cstmt.getStmtLabel_(),
+                    cstmt.sql_.trim(), cstmt.queryTimeout_,
+                    cstmt.resultSetHoldability_, cstmt.fetchSize_);
+            if (isStatementCachingEnabled()) {
+                addPreparedStatement(this, cstmt.sql_.trim(), cstmt,
+                        ResultSet.TYPE_FORWARD_ONLY,
+                        ResultSet.CONCUR_READ_ONLY, holdability_);
+            }
+            addElement(cstmt);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareCall(\"" + sql
+                    + "\") returns CallableStatement ["
+                    + cstmt.getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TCallableStatement(cstmt, out_);
+            }
+            return cstmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareCall_L].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization prepareCall() is now synchronized
+     */
+public synchronized CallableStatement prepareCall(String sql,
+            int resultSetType, int resultSetConcurrency) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareCall(\"" + sql + "\","
+                + resultSetType + "," + resultSetConcurrency + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareCall_LII].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareCall_LII].methodParameters("sql=" + sql
+                + ", resultSetType=" + resultSetType
+                + ", resultSetConcurrency=" + resultSetConcurrency);
+        try {
+            SQLMXCallableStatement cstmt;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            gcStmts();
+            if (isStatementCachingEnabled()) {
+                cstmt = (SQLMXCallableStatement) getPreparedStatement(this,
+                        sql.trim(), resultSetType, resultSetConcurrency, holdability_);
+                if (cstmt != null) {
+                    if (out_ != null) {
+                        out_.println(getTraceId() + "prepareCall(\"" + sql + "\","
+                                + resultSetType + "," + resultSetConcurrency
+                                + ") returns CallableStatement ["
+                                + cstmt.getStmtLabel_() + "]");
+                        if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                            out_.println(getTraceId() + "prepareCall(String,resultSetType,resultSetConcurrency) "
+                                    + cstmt.stmtId_+"\" GOT STMT FROM CACHE ");
+                        }
+                    }
+                    if(out_ != null) {
+                        return new TCallableStatement(cstmt, out_);
+                    }
+                    return cstmt;
+
+                }
+            }
+            cstmt = new SQLMXCallableStatement(this, sql, resultSetType,
+                    resultSetConcurrency);
+
+            pStmtCount++;
+            if (out_ != null) {
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() + "prepareCall(String,resultSetType,resultSetConcurrency) "
+                            + " PREPARED STMT - " + "\""
+                            + cstmt.stmtId_ + "\"");
+                    out_.println(getTraceId() + "prepareCall(String,resultSetType,resultSetConcurrency) "
+                            + "\""+"PREPARED STMT COUNT:"+this.pStmtCount
+                            + "\"");
+                }
+            }
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(cstmt);
+            cstmt.prepareCall(server_, getDialogueId_(), getTxid_(),
+                    autoCommit_, transactionMode_, cstmt.getStmtLabel_(),
+                    cstmt.sql_.trim(), cstmt.queryTimeout_,
+                    cstmt.resultSetHoldability_, cstmt.fetchSize_);
+            if (isStatementCachingEnabled()) {
+                addPreparedStatement(this, cstmt.sql_.trim(), cstmt,
+                        resultSetType, resultSetConcurrency, holdability_);
+            }
+            addElement(cstmt);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareCall(\"" + sql + "\","
+                    + resultSetType + "," + resultSetConcurrency
+                    + ") returns CallableStatement ["
+                    + cstmt.getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TCallableStatement(cstmt, out_);
+            }
+            return cstmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareCall_LII].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization prepareCall() is now synchronized
+     */
+public synchronized CallableStatement prepareCall(String sql,
+            int resultSetType, int resultSetConcurrency,
+            int resultSetHoldability) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareCall(\"" + sql + "\","
+                + resultSetType + "," + resultSetConcurrency + ","
+                + resultSetHoldability + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareCall_LIII].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareCall_LIII].methodParameters("sql=" + sql
+                + ", resultSetType=" + resultSetType
+                + ", resultSetConcurrency=" + resultSetConcurrency
+                + ", resultSetHoldability=" + resultSetHoldability);
+        try {
+            SQLMXCallableStatement cstmt;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            gcStmts();
+            if (isStatementCachingEnabled()) {
+                cstmt = (SQLMXCallableStatement) getPreparedStatement(this, sql
+                        .trim(), resultSetType, resultSetConcurrency,
+                        resultSetHoldability);
+                if (cstmt != null) {
+                    if (out_ != null) {
+                        out_.println(getTraceId() + "prepareCall(\"" + sql + "\","
+                                + resultSetType + "," + resultSetConcurrency + ","
+                                + resultSetHoldability + ") returns CallableStatement ["
+                                + cstmt.getStmtLabel_() + "]");
+                        if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                            out_.println(getTraceId() + "repareCall(String,resultSetType,resultSetConcurrency,resultSetHoldability)"
+                                    + cstmt.stmtId_+"\"+ GOT STMT FROM CACHE ");
+                        }
+                    }
+
+                    if(out_ != null) {
+                        return new TCallableStatement(cstmt, out_);
+                    }
+
+                    return cstmt;
+                }
+
+            }
+            cstmt = new SQLMXCallableStatement(this, sql, resultSetType,
+                    resultSetConcurrency, resultSetHoldability);
+
+            pStmtCount++;
+            if (out_ != null) {
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() + "prepareCall(String,resultSetType,resultSetConcurrency,resultSetHoldability) "
+                            + " PREPARED STMT - " + "\""
+                            + cstmt.stmtId_ + "\"");
+                    out_.println(getTraceId() + "prepareCall(String,resultSetType,resultSetConcurrency,resultSetHoldability) "
+                            +"\""+"PREPARED STMT COUNT:"+this.pStmtCount
+                            + "\"");
+                }
+            }
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(cstmt);
+            cstmt.prepareCall(server_, getDialogueId_(), getTxid_(),
+                    autoCommit_, transactionMode_, cstmt.getStmtLabel_(),
+                    cstmt.sql_.trim(), cstmt.queryTimeout_,
+                    cstmt.resultSetHoldability_, cstmt.fetchSize_);
+            if (isStatementCachingEnabled()) {
+                addPreparedStatement(this, cstmt.sql_.trim(), cstmt,
+                        resultSetType, resultSetConcurrency,
+                        resultSetHoldability);
+            }
+            addElement(cstmt);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareCall(\"" + sql + "\","
+                    + resultSetType + "," + resultSetConcurrency + ","
+                    + resultSetHoldability + ") returns CallableStatement ["
+                    + cstmt.getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TCallableStatement(cstmt, out_);
+            }
+            return cstmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareCall_LIII].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization prepareStatement() is now synchronized
+     */
+public synchronized PreparedStatement prepareStatement(String sql)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareStatement_L].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareStatement_L].methodParameters("sql=" + sql);
+        try {
+            SQLMXPreparedStatement pstmt;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            gcStmts();
+            if (isStatementCachingEnabled()) {
+                pstmt = (SQLMXPreparedStatement) getPreparedStatement(this,
+                        sql.trim(), ResultSet.TYPE_FORWARD_ONLY,
+                        ResultSet.CONCUR_READ_ONLY, holdability_);
+                if (pstmt != null) {
+                    if (out_ != null) {
+                        out_.println(getTraceId() + "prepareStatement(\"" + sql
+                                + "\") returns PreparedStatement ["
+                                + (pstmt).getStmtLabel_() + "]");
+                        if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                            out_.println(getTraceId() + "prepareStatement(String) "
+                                    + pstmt.stmtId_+"\"+ GOT STMT FROM CACHE ");
+                        }
+                    }
+                    if(out_ != null) {
+                        return new TPreparedStatement(pstmt, out_);
+                    }
+                    return pstmt;
+                }
+            }
+            pstmt = new SQLMXPreparedStatement(this, sql);
+
+            pStmtCount++;
+            if (out_ != null) {
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() + "prepareStatement(String) "
+                            + " PREPARED STMT - " + "\""
+                            + pstmt.stmtId_ + "\"");
+                    out_.println(getTraceId() + "prepareStatement(String) "
+                            +"\""+"PREPARED STMT COUNT:"+this.pStmtCount
+                            + "\"");
+                }
+            }
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(pstmt);
+
+            // not insert
+            int batchBindingSizePrev = 0;
+//			if (SQLMXConnection.getSqlStmtType(sql) != SQLMXConnection.TYPE_INSERT
+//					&& SQLMXConnection.getSqlStmtType(sql) != SQLMXConnection.TYPE_INSERT_PARAM) {
+//
+//				batchBindingSizePrev = batchBindingSize_;
+//				batchBindingSize_ = 0;
+//			}
+            if ( pstmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    && pstmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM
+                    && pstmt.getSqlType() != SQLMXConnection.TYPE_UPDATE
+                    && pstmt.getSqlType() != SQLMXConnection.TYPE_DELETE
+            )
+            {
+
+                batchBindingSizePrev = this.t2props.getBatchBinding();
+                batchBindingSize_ = 0;
+            }
+
+            // MFC - if modulecaching is on call cpqprepare directly
+            // Renamed the modulecaching property as enableMFC
+            if (this.t2props.getEnableMFC().equalsIgnoreCase("on") && this.t2props.getBatchBinding() ==0) {
+
+                synchronized (SQLMXConnection.lockForMFCPrep) {
+                    pstmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
+                            autoCommit_, transactionMode_, "", moduleVersion_,
+                            moduleTimestamp_, pstmt.getStmtLabel_(),
+                            pstmt.isSelect_, pstmt.queryTimeout_,
+                            pstmt.resultSetHoldability_, batchBindingSize_,
+                            pstmt.fetchSize_, sql.trim(),getSqlStmtTypeForMFC(sql.trim()));
+                }
+            } else {
+                pstmt.prepare(server_, getDialogueId_(), getTxid_(), autoCommit_,
+                        pstmt.getStmtLabel_(), pstmt.sql_.trim(), pstmt.isSelect_,
+                        pstmt.queryTimeout_, pstmt.resultSetHoldability_,
+                        batchBindingSize_, pstmt.fetchSize_);
+            }
+
+            // value
+//			if (SQLMXConnection.getSqlStmtType(sql) != SQLMXConnection.TYPE_INSERT
+//					&& SQLMXConnection.getSqlStmtType(sql) != SQLMXConnection.TYPE_INSERT_PARAM) {
+//
+//				batchBindingSize_ = batchBindingSizePrev;
+//			}
+            if (pstmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    && pstmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM
+                    && pstmt.getSqlType() != SQLMXConnection.TYPE_UPDATE
+                    && pstmt.getSqlType() != SQLMXConnection.TYPE_DELETE
+            )
+            {
+                batchBindingSize_ = batchBindingSizePrev;
+            }
+            // End
+
+            if (isStatementCachingEnabled()) {
+                addPreparedStatement(this, pstmt.sql_.trim(), pstmt,
+                        ResultSet.TYPE_FORWARD_ONLY,
+                        ResultSet.CONCUR_READ_ONLY, holdability_);
+            }
+            addElement(pstmt);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareStatement(\"" + sql
+                    + "\") returns PreparedStatement ["
+                    + (pstmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TPreparedStatement(pstmt, out_);
+            }
+            return pstmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareStatement_L].methodExit();
+        }
+    }
+
+    // Do not add LOB statements to the statement cache.
+    // Set as protected to allow SQLMXDataLocator calls.
+    /*
+     * RFE: Connection synchronization prepareLobStatement() is now synchronized
+     */
+protected synchronized PreparedStatement prepareLobStatement(String sql)
+    throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareLobStatement].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareLobStatement].methodParameters("sql=" + sql);
+        try {
+            SQLMXPreparedStatement stmt;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(null, "invalid_connection",
+                    null);
+
+            stmt = new SQLMXPreparedStatement(this, sql);
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(stmt);
+
+            // not insert
+            int batchBindingSizePrev = 0;
+//			if (SQLMXConnection.getSqlStmtType(sql) != SQLMXConnection.TYPE_INSERT
+//					&& SQLMXConnection.getSqlStmtType(sql) != SQLMXConnection.TYPE_INSERT_PARAM) {
+//
+//				batchBindingSizePrev = batchBindingSize_;
+//				batchBindingSize_ = 0;
+//			}
+            if (stmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_UPDATE
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_DELETE
+            ) {
+
+                batchBindingSizePrev = this.t2props.getBatchBinding();
+                batchBindingSize_ = 0;
+            }
+
+            stmt.prepare(server_, getDialogueId_(), getTxid_(), autoCommit_,
+                    stmt.getStmtLabel_(), stmt.sql_.trim(), stmt.isSelect_,
+                    stmt.queryTimeout_, stmt.resultSetHoldability_,
+                    batchBindingSize_, stmt.fetchSize_);
+
+            if (stmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_UPDATE
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_DELETE
+            )
+            {
+
+                batchBindingSize_ = batchBindingSizePrev;
+            }
+
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareLobStatement].methodExit();
+        }
+    }
+
+public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                + autoGeneratedKeys + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareStatement_LI].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareStatement_LI].methodParameters("sql=" + sql
+                + ", autoGeneratedKeys=" + autoGeneratedKeys);
+        try {
+            if (autoGeneratedKeys != SQLMXStatement.NO_GENERATED_KEYS)
+            throw Messages.createSQLException(locale_,
+                    "auto_generated_keys_not_supported", null);
+            SQLMXPreparedStatement stmt = (SQLMXPreparedStatement) prepareStatement(sql);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                    + autoGeneratedKeys + ") returns PreparedStatement ["
+                    + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TPreparedStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareStatement_LI].methodExit();
+        }
+    }
+
+public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                + columnIndexes + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareStatement_LI_array].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareStatement_LI_array]
+        .methodParameters("sql=" + sql + ", int["
+                + columnIndexes.length + "] columnIndexes");
+        try {
+            if (columnIndexes != null && columnIndexes.length > 0)
+            throw Messages.createSQLException(locale_,
+                    "auto_generated_keys_not_supported", null);
+            SQLMXPreparedStatement stmt = (SQLMXPreparedStatement) prepareStatement(sql);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                    + columnIndexes + ") returns PreparedStatement ["
+                    + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TPreparedStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareStatement_LI_array].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization prepareStatement() is now synchronized
+     */
+public synchronized PreparedStatement prepareStatement(String sql,
+            int resultSetType, int resultSetConcurrency) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                + resultSetType + "," + resultSetConcurrency + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareStatement_LII].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareStatement_LII].methodParameters("sql=" + sql
+                + ", resultSetType=" + resultSetType
+                + ", resultSetConcurrency=" + resultSetConcurrency);
+        try {
+            SQLMXPreparedStatement stmt;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            gcStmts();
+            if (isStatementCachingEnabled()) {
+                stmt = (SQLMXPreparedStatement) getPreparedStatement(this, sql
+                        .trim(), resultSetType, resultSetConcurrency,
+                        holdability_);
+                if (stmt != null) {
+                    if (out_ != null) {
+                        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                                + resultSetType + "," + resultSetConcurrency
+                                + ") returns PreparedStatement ["
+                                + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+                        if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                            out_.println(getTraceId() + "prepareStatement(String,resultSetType,resultSetConcurrency) "
+                                    + stmt.stmtId_+"\"+ GOT STMT FROM CACHE ");
+                        }
+                    }
+                    if(out_ != null) {
+                        return new TPreparedStatement(stmt, out_);
+                    }
+                    return stmt;
+                }
+            }
+            stmt = new SQLMXPreparedStatement(this, sql, resultSetType,
+                    resultSetConcurrency);
+
+            pStmtCount++;
+            if (out_ != null) {
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() + "prepareStatement(String,resultSetType,resultSetConcurrency) "
+                            + " PREPARED STMT - " + "\""
+                            + stmt.stmtId_ + "\"");
+                    out_.println(getTraceId() + "prepareStatement(String,resultSetType,resultSetConcurrency) "
+                            +"\""+"PREPARED STMT COUNT:"+this.pStmtCount
+                            + "\"");
+                }
+            }
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(stmt);
+
+            // is not insert
+            int batchBindingSizePrev = 0;
+            if (stmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM) {
+
+                batchBindingSizePrev = this.t2props.getBatchBinding();
+                batchBindingSize_ = 0;
+            }
+
+            // MFC - if modulecaching is on call cpqprepare directly
+            // Renamed the modulecaching property as enableMFC
+            if (this.t2props.getEnableMFC().equalsIgnoreCase("on") && this.t2props.getBatchBinding() ==0) {
+
+                synchronized (SQLMXConnection.lockForMFCPrep) {
+                    stmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
+                            autoCommit_, transactionMode_, "", moduleVersion_,
+                            moduleTimestamp_, stmt.getStmtLabel_(),
+                            stmt.isSelect_, stmt.queryTimeout_,
+                            stmt.resultSetHoldability_, batchBindingSize_,
+                            stmt.fetchSize_, sql.trim(),getSqlStmtTypeForMFC(sql.trim()));
+                }
+            } else {
+                stmt.prepare(server_, getDialogueId_(), getTxid_(),
+                        autoCommit_, stmt.getStmtLabel_(), stmt.sql_.trim(),
+                        stmt.isSelect_, stmt.queryTimeout_,
+                        stmt.resultSetHoldability_, batchBindingSize_,
+                        stmt.fetchSize_);
+            }
+            if (stmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM) {
+
+                batchBindingSize_ = batchBindingSizePrev;
+            }
+            if (isStatementCachingEnabled()) {
+                addPreparedStatement(this, stmt.sql_.trim(), stmt,
+                        resultSetType, resultSetConcurrency, holdability_);
+            }
+            addElement(stmt);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                    + resultSetType + "," + resultSetConcurrency
+                    + ") returns PreparedStatement ["
+                    + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TPreparedStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareStatement_LII].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization prepareStatement() is now synchronized
+     */
+public synchronized PreparedStatement prepareStatement(String sql,
+            int resultSetType, int resultSetConcurrency,
+            int resultSetHoldability) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                + resultSetType + "," + resultSetConcurrency + ","
+                + resultSetHoldability + ")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareStatement_LIII].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareStatement_LIII].methodParameters("sql=" + sql
+                + ", resultSetType=" + resultSetType
+                + ", resultSetConcurrency=" + resultSetConcurrency
+                + ", resultSetHoldability=" + resultSetHoldability);
+        try {
+            SQLMXPreparedStatement stmt;
+
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            connectInit();
+            gcStmts();
+            if (isStatementCachingEnabled()) {
+                stmt = (SQLMXPreparedStatement) getPreparedStatement(this, sql
+                        .trim(), resultSetType, resultSetConcurrency,
+                        resultSetHoldability);
+                if (stmt != null) {
+                    if (out_ != null) {
+                        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                                + resultSetType + "," + resultSetConcurrency + ","
+                                + resultSetHoldability + ") returns PreparedStatement ["
+                                + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+                        if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                            out_.println(getTraceId() + "prepareStatement(String,resultSetType,resultSetConcurrency,resultSetHoldability) "
+                                    + stmt.stmtId_+"\"+ GOT STMT FROM CACHE ");
+                        }
+                    }
+                    if(out_ != null) {
+                        return new TPreparedStatement(stmt, out_);
+                    }
+                    return stmt;
+                }
+            }
+            stmt = new SQLMXPreparedStatement(this, sql, resultSetType,
+                    resultSetConcurrency, resultSetHoldability);
+
+            pStmtCount++;
+            if (out_ != null) {
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() + "prepareStatement(String,resultSetType,resultSetConcurrency,resultSetHoldability) "
+                            + " PREPARED STMT - " + "\""
+                            + stmt.stmtId_ + "\"");
+                    out_.println(getTraceId() + "prepareStatement(String,resultSetType,resultSetConcurrency,resultSetHoldability) "
+                            +"\""+"PREPARED STMT COUNT:"+this.pStmtCount
+                            + "\"");
+                }
+            }
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(stmt);
+
+            // is not insert
+            int batchBindingSizePrev = 0;
+            if (stmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    &&stmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM) {
+
+                batchBindingSizePrev = this.t2props.getBatchBinding();
+                batchBindingSize_ = 0;
+            }
+
+            // MFC - if modulecaching is on call cpqprepare directly
+            // Renamed the modulecaching property as enableMFC
+            if (this.t2props.getEnableMFC().equalsIgnoreCase("on") && this.t2props.getBatchBinding() ==0) {
+
+                synchronized (SQLMXConnection.lockForMFCPrep) {
+                    stmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
+                            autoCommit_, transactionMode_, "", moduleVersion_,
+                            moduleTimestamp_, stmt.getStmtLabel_(),
+                            stmt.isSelect_, stmt.queryTimeout_,
+                            stmt.resultSetHoldability_, batchBindingSize_,
+                            stmt.fetchSize_, sql.trim(),getSqlStmtTypeForMFC(sql.trim()));
+                }
+            } else {
+                stmt.prepare(server_, getDialogueId_(), getTxid_(),
+                        autoCommit_, stmt.getStmtLabel_(), stmt.sql_.trim(),
+                        stmt.isSelect_, stmt.queryTimeout_,
+                        stmt.resultSetHoldability_, batchBindingSize_,
+                        stmt.fetchSize_);
+            }
+
+            if (stmt.getSqlType() != SQLMXConnection.TYPE_INSERT
+                    && stmt.getSqlType() != SQLMXConnection.TYPE_INSERT_PARAM) {
+
+                batchBindingSize_ = batchBindingSizePrev;
+            }
+
+            if (isStatementCachingEnabled()) {
+                addPreparedStatement(this, stmt.sql_.trim(), stmt,
+                        resultSetType, resultSetConcurrency,
+                        resultSetHoldability);
+            }
+            addElement(stmt);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareStatement(\"" + sql + "\","
+                    + resultSetType + "," + resultSetConcurrency + ","
+                    + resultSetHoldability
+                    + ") returns PreparedStatement ["
+                    + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TPreparedStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareStatement_LIII].methodExit();
+        }
+    }
+
+public PreparedStatement prepareStatement(String sql, String[] columnNames)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "prepareStatement(\"" + sql + "\")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_prepareStatement_LL_array].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_prepareStatement_LL_array].methodParameters("sql="
+                + sql + ", String[" + columnNames.length + "] columnNames");
+        try {
+            if (columnNames != null && columnNames.length > 0)
+            throw Messages.createSQLException(locale_,
+                    "auto_generated_keys_not_supported", null);
+            SQLMXPreparedStatement stmt = (SQLMXPreparedStatement) prepareStatement(sql);
+            if (out_ != null)
+            out_.println(getTraceId() + "prepareStatement(\"" + sql
+                    + "\") returns PreparedStatement ["
+                    + ((SQLMXStatement) stmt).getStmtLabel_() + "]");
+            if (out_ != null) {
+                return new TPreparedStatement(stmt, out_);
+            }
+            return stmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_prepareStatement_LL_array].methodExit();
+        }
+    }
+
+    //**************************************************************************
+    // * Function: releaseSavepoint(Savepoint)
+    // *
+    // * Description: This is a required method for the JDBC 3.0 API. This
+    // method
+    // * takes a Savepoint object as a parameter and removes it from
+    // * current transaction.
+    // *
+    // * Input: Savepoint object, one that was previous saved.
+    // *
+    // * NOTE: This is an unsupported function, calling it will cause an
+    // * unsupported exception to be thown.
+    // *
+    //**************************************************************************
+    // *
+
+public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_releaseSavepoint].methodEntry();
+        try {
+            clearWarnings();
+            Messages.throwUnsupportedFeatureException(locale_,
+                    "releaseSavepoint()");
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_releaseSavepoint].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization rollback() is now synchronized.
+     */
+public synchronized void rollback() throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "rollback()");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_rollback_V].methodEntry();
+        try {
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            if (autoCommit_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_commit_mode", null);
+
+            if (beginTransFlag_) {
+                /*
+                 * Transaction was started using Connection.begintransaction()
+                 * API, set the autoCommit_ flag to true.
+                 */
+                autoCommit_ = true;
+                beginTransFlag_ = false;
+            }
+            Statement cs = null;
+            try {
+                // commit the Transaction
+                cs = this.createStatement();
+                cs.execute("rollback");
+            } catch (SQLException se) {
+                if (se.getErrorCode() != -8609)
+                throw se;
+            }finally {
+                if(cs != null) {
+                    try {cs.close();} catch(Exception ee) {}
+                }
+                setTxid_(0);
+            }
+        }finally {
+            if (JdbcDebugCfg.traceActive)
+            debug[methodId_rollback_V].traceOut(JdbcDebug.debugLevelEntry,
+                    "beginTransFlag_ = " + beginTransFlag_
+                    + "; autoCommit_ = " + autoCommit_
+                    + "; txid_ = " + getTxid_());
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_rollback_V].methodExit();
+        }
+    }
+
+    //**************************************************************************
+    // * Function: rollback(SavePoint)
+    // *
+    // * Description: This is a required method for the JDBC 3.0 API. This
+    // method
+    // * takes a Savepoint object as a parameter and roll back to when
+    // * that Savepoint object was taken.
+    // *
+    // * Input: Savepoint object, one that was previous saved.
+    // *
+    // * NOTE: This is an unsupported function, calling it will cause an
+    // * unsupported exception to be thown.
+    // *
+    //**************************************************************************
+    // *
+
+public void rollback(Savepoint savepoint) throws SQLException {
+        if (out_ != null) {
+            out_.println(getTraceId() + "rollback (" + savepoint + ")");
+        }
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_rollback_L].methodEntry();
+        try {
+            clearWarnings();
+            Messages.throwUnsupportedFeatureException(locale_,
+                    "rollback(Savepoint)");
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_rollback_L].methodExit();
+        }
+    }
+
+public void setAutoCommit(boolean autoCommit) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "setAutoCommit(" + autoCommit + ")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setAutoCommit].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_setAutoCommit].methodParameters("autoCommit="
+                + autoCommit);
+        try {
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_, "invalid_connection", null);
+            if(this.getAutoCommit() == autoCommit) {
+                return;
+            }
+            //changes to comply with standards, if autocommit mode is same then NO-OP
+            // Don't allow autoCommit false when internal txn mode
+            if (transactionMode_ == TXN_MODE_INTERNAL)
+            autoCommit_ = true;
+            else
+            {
+                if (autoCommit_ != autoCommit)
+                {
+                    if (connectInitialized_)
+                    setAutoCommit(server_, getDialogueId_(), autoCommit);
+                    autoCommit_ = autoCommit;
+                }
+            }
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setAutoCommit].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization setCatalog() is now synchronized.
+     */
+public synchronized void setCatalog(String catalog) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "setCatalog(\"" + catalog + "\")");
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setCatalog].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_setCatalog].methodParameters("catalog=" + catalog);
+        try {
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            if (catalog != null) {
+                setCatalog(server_, getDialogueId_(), catalog);
+                if (!catalog.startsWith("\""))
+                catalog_ = catalog.toUpperCase();
+                else
+                catalog_ = catalog;
+                updateConnectionReusability(SQL_SET_CATALOG);
+            }
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setCatalog].methodExit();
+        }
+    }
+
+public void setHoldability(int holdability) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "setHoldability(\"" + holdability + "\")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setHoldability].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_setHoldability].methodParameters("holdability="
+                + holdability);
+        try {
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            if (holdability != SQLMXResultSet.HOLD_CURSORS_OVER_COMMIT
+                    && holdability != SQLMXResultSet.CLOSE_CURSORS_AT_COMMIT)
+            throw Messages.createSQLException(locale_,
+                    "invalid_holdability", null);
+            holdability_ = holdability;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setHoldability].methodExit();
+        }
+    }
+
+public void setReadOnly(boolean readOnly) throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "setReadOnly(" + readOnly + ")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setReadOnly].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_setReadOnly]
+        .methodParameters("readOnly=" + readOnly);
+        try {
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            // setReadOnly(server_, dialogueId_, readOnly);
+            isReadOnly_ = readOnly;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setReadOnly].methodExit();
+        }
+    }
+
+    //**************************************************************************
+    // * Function: setSavepoint(String)
+    // *
+    // * Description: This is a required method for the JDBC 3.0 API. This
+    // method
+    // * takes a String object as a parameter and returns a Savepoint
+    // * object.
+    // *
+    // * Input: String Object - Optional name of the setpoint.
+    // * Returns: Setpoint Object - used to roll back to this point in time.
+    // *
+    // * NOTE: This is an unsupported function, calling it will cause an
+    // * unsupported exception to be thown.
+    // *
+    //**************************************************************************
+    // *
+
+public Savepoint setSavepoint(String name) throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setSavepoint_L].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_setSavepoint_L].methodParameters("name=" + name);
+        try {
+            clearWarnings();
+            Messages.throwUnsupportedFeatureException(locale_, "setSavepoint");
+            return null;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setSavepoint_L].methodExit();
+        }
+    }
+
+    //**************************************************************************
+    // * Function: setSavepoint()
+    // *
+    // * Description: This is a required method for the JDBC 3.0 API. This
+    // method
+    // * takes no parameter and returns a Savepoint object.
+    // *
+    // * Input: None.
+    // * Returns: Setpoint Object - used to roll back to this point in time.
+    // *
+    // * NOTE: This is an unsupported function, calling it will cause an
+    // * unsupported exception to be thown.
+    // *
+    //**************************************************************************
+    // *
+
+public Savepoint setSavepoint() throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setSavepoint_V].methodEntry();
+        try {
+            clearWarnings();
+            Messages.throwUnsupportedFeatureException(locale_, "setSavepoint");
+            return null;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setSavepoint_V].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization setTransactionIsolation() is now
+     * synchronized.
+     */
+public synchronized void setTransactionIsolation(int level)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "setTransactionIsolation(" + level + ")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setTransactionIsolation].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_setTransactionIsolation].methodParameters("level="
+                + level);
+        try {
+            clearWarnings();
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            switch (level) {
+                case TRANSACTION_NONE:
+                case TRANSACTION_READ_UNCOMMITTED:
+                case TRANSACTION_READ_COMMITTED:
+                case TRANSACTION_REPEATABLE_READ:
+                case TRANSACTION_SERIALIZABLE:
+                // Check if connection is open
+                setTransactionIsolation(server_, getDialogueId_(),
+                        mapTxnIsolation(level));
+                transactionIsolation_ = level;
+                updateConnectionReusability(SQL_SET_TRANSACTION);
+                break;
+                default:
+                throw Messages.createSQLException(locale_,
+                        "invalid_transaction_isolation", null);
+            }
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setTransactionIsolation].methodExit();
+        }
+    }
+
+    // JDK 1.2
+public void setTypeMap(java.util.Map<String, Class<?>> map)
+    throws SQLException {
+        if (out_ != null)
+        out_.println(getTraceId() + "setTypeMap(" + map + ")");
+
+        if (out_ != null)
+        out_.println(getTraceId() + "setTypeMap(" + map + ")");
+
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_setTypeMap].methodEntry();
+        try {
+            clearWarnings();
+            userMap_ = map;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_setTypeMap].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization cpqPrepareStatement() is now
+     * synchronized.
+     */
+    // Method to be used by SQLJ-O
+public synchronized PreparedStatement cpqPrepareStatement(
+            String moduleName, int moduleVersion, long moduleTimestamp,
+            String stmtName, boolean isSelect) throws SQLException {
+        if (out_ != null) {
+            out_.println(getTraceId() + "cpqPrepareStatement(\"" + moduleName
+                    + "\"," + moduleTimestamp + ", \"" + stmtName + "\", \""
+                    + isSelect + ")");
+        }
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_cpqPrepareStatement].methodEntry();
+        try {
+            SQLMXPreparedStatement pstmt;
+
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            gcStmts();
+            pstmt = new SQLMXPreparedStatement(this, moduleName, moduleVersion,
+                    moduleTimestamp, stmtName, isSelect, holdability_);
+            addElement(pstmt);
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(pstmt);
+
+            pstmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
+                    autoCommit_, transactionMode_, pstmt.moduleName_,
+                    pstmt.moduleVersion_, pstmt.moduleTimestamp_, pstmt
+                    .getStmtLabel_(), pstmt.isSelect_,
+                    pstmt.queryTimeout_, pstmt.resultSetHoldability_,
+                    batchBindingSize_, pstmt.fetchSize_, "",false);
+            if (out_ != null) {
+                out_.println(getTraceId() + "cpqPrepareStatement(\"" + moduleName
+                        + "\"," + moduleTimestamp + ", \"" + stmtName + "\", \""
+                        + isSelect + ") returns PreparedStatement ["
+                        + pstmt.getStmtLabel_() + "]");
+            }
+            if (out_ != null) {
+                return new TPreparedStatement(pstmt, out_);
+            }
+            return pstmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_cpqPrepareStatement].methodExit();
+        }
+    }
+
+    // Method to be used by SQLJ-O
+public CallableStatement cpqPrepareCall(String moduleName,
+            int moduleVersion, long moduleTimestamp, String stmtName)
+    throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_cpqPrepareCall].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_cpqPrepareCall].methodParameters("moduleName="
+                + moduleName + ", moduleVersion=" + moduleVersion
+                + ", moduleTimestamp=" + moduleTimestamp + ", stmtName="
+                + stmtName);
+        try {
+            SQLMXCallableStatement cstmt;
+
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            gcStmts();
+            cstmt = new SQLMXCallableStatement(this, moduleName, moduleVersion,
+                    moduleTimestamp, stmtName);
+            addElement(cstmt);
+
+            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
+            printIdMapEntry(cstmt);
+
+            cstmt.cpqPrepareCall(server_, getDialogueId_(), getTxid_(),
+                    autoCommit_, transactionMode_, cstmt.moduleName_,
+                    cstmt.moduleVersion_, cstmt.moduleTimestamp_, cstmt
+                    .getStmtLabel_(), cstmt.queryTimeout_,
+                    cstmt.resultSetHoldability_, cstmt.fetchSize_);
+            return cstmt;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_cpqPrepareCall].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization begintransaction() is now synchronized.
+     */
+    // Method to be used by SQLJ-O
+public synchronized void begintransaction() throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_begintransaction].methodEntry();
+        try {
+            int txid;
+
+            if (isClosed_)
+            throw Messages.createSQLException(locale_,
+                    "invalid_connection", null);
+            if (getTxid_() != 0)
+            throw Messages.createSQLException(locale_,
+                    "invalid_transaction_state", null);
+
+            txid = beginTransaction(server_, getDialogueId_());
+            if (txid != 0) {
+                setTxid_(txid);
+                autoCommit_ = false;
+
+                /*
+                 * This flag was introduced to resolve the problem with BEGIN
+                 * WORK COMMIT WORK and ROLLBACK WORK in SQLJ clause. The
+                 * autoCommit flag set to false by SQLJ BEGIN WORK should to
+                 * reset to true in SQLJ COMMIT WORK and ROLLBACK WORK.
+                 */
+
+                beginTransFlag_ = true;
+            }
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_begintransaction].methodExit();
+        }
+    }
+
+    // Other methods
+private int mapTxnIsolation(int level) {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_mapTxnIsolation].methodEntry();
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_mapTxnIsolation].methodParameters("level=" + level);
+        try {
+            int isolationLevel;
+
+            switch (level) {
+                case TRANSACTION_NONE: // May be we default to SQL/MX default
+                isolationLevel = SQL_TXN_READ_COMMITTED;
+                break;
+                case TRANSACTION_READ_COMMITTED:
+                isolationLevel = SQL_TXN_READ_COMMITTED;
+                break;
+                case TRANSACTION_READ_UNCOMMITTED:
+                isolationLevel = SQL_TXN_READ_UNCOMMITTED;
+                break;
+                case TRANSACTION_REPEATABLE_READ:
+                isolationLevel = SQL_TXN_REPEATABLE_READ;
+                break;
+                case TRANSACTION_SERIALIZABLE:
+                isolationLevel = SQL_TXN_SERIALIZABLE;
+                break;
+                default:
+                isolationLevel = SQL_TXN_READ_COMMITTED;
+                break;
+            }
+            return isolationLevel;
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_mapTxnIsolation].methodExit();
+        }
+    }
+
+    long getNextRSCount() {
+        return ++rsCount_;
+    }
+
+    /*
+     * RFE: Connection synchronization gcStmts()is now synchronized.
+     */
+    synchronized void gcStmts() {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_gcStmts].methodEntry();
+        try {
+            Reference pRef;
+            //Venu changed stmtId from int to long for 64 bit
+            long stmtId;
+            Long stmtObject;
+
+            while ((pRef = refQ_.poll()) != null) {
+                Object obj = refToStmt_.get(pRef);
+                if (obj != null) {
+                    stmtObject = (Long)obj;
+                    // All PreparedStatement objects are added to HashMap
+                    // Only Statement objects that produces ResultSet are added
+                    // to
+                    // HashMap
+                    // Hence stmtLabel could be null
+                    if (stmtObject != null) {
+                        stmtId = stmtObject.intValue();
+                        try {
+                            SQLMXStatement.close(server_, getDialogueId_(),
+                                    stmtId, true);
+                        } catch (SQLException e) {
+                        }finally {
+                            refToStmt_.remove(pRef);
+                        }
+                    }
+                }
+            }
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_gcStmts].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization removeElement()is now synchronized.
+     */
+    synchronized void removeElement(SQLMXStatement stmt) {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_removeElement_L].methodEntry();
+        try {
+            // if (stmt.pRef_.isEnqueued())
+            // don't know what to do
+            refToStmt_.remove(stmt.pRef_);
+            stmt.pRef_.clear();
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_removeElement_L].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization addElement()is now synchronized.
+     */
+    synchronized void addElement(SQLMXStatement stmt) {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_addElement].methodEntry();
+        try {
+            //venu changed from Int to Long
+            refToStmt_.put(stmt.pRef_, new Long(stmt.stmtId_));
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_addElement].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization connectInit() is now synchronized.
+     */
+    synchronized void connectInit() throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_connectInit].methodEntry();
+        // Big Num Changes
+        //Current tx = new Current();
+        //int status =0;
+        try {
+            if (!connectInitialized_) {
+                /*		status = tx.get_status();
+                 if(status == com.tandem.tmf.Current.StatusNoTransaction){
+                 tx.begin();
+                 }*/
+                try {
+                    boolean blnCQD = System.getProperty(
+                            "t2jdbc.cqdDoomUserTxn", "OFF").equalsIgnoreCase(
+                            "ON")
+                    || System.getProperty("cqdDoomUserTxn", "OFF")
+                    .equalsIgnoreCase("ON");
+                    // MFC added two more parameters
+
+                    connectInit(server_, getDialogueId_(), catalog_, schema_,
+                            mploc_, isReadOnly_, autoCommit_,
+                            mapTxnIsolation(transactionIsolation_),
+                            loginTimeout_, queryTimeout_, enableMFC_,
+                            compiledModuleLocation_, blnCQD,
+                            statisticsIntervalTime_, statisticsLimitTime_, statisticsType_, programStatisticsEnabled_, statisticsSqlPlanEnabled_
+                    );
+
+                    if (iso88591EncodingOverride_ != null)
+                    setCharsetEncodingOverride(server_, getDialogueId_(),
+                            SQLMXDesc.SQLCHARSETCODE_ISO88591,
+                            iso88591EncodingOverride_);
+                } catch (SQLException e) {
+                    /*	if(status == com.tandem.tmf.Current.StatusNoTransaction){
+                     tx.rollback();
+                     }*/
+                    if (pc_ != null)
+                    pc_.sendConnectionErrorEvent(e);
+                    else
+                    close(true, true);
+                    throw e;
+                }
+                connectInitialized_ = true;
+                /*	if(status == com.tandem.tmf.Current.StatusNoTransaction){
+                 tx.rollback();
+                 }*/
+            }
+
+        }
+        /*catch (FSException e) {
+         if(status == com.tandem.tmf.Current.StatusNoTransaction){
+         try {
+         tx.rollback();
+         } catch (FSException e1) {
+         }
+         }
+         }*/
+        finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_connectInit].methodExit();
+
+        }
+    }
+
+    void removeElement() {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_removeElement_V].methodEntry();
+        try {
+            if (ds_ != null) {
+                ds_.weakConnection.removeElement(this);
+                ds_ = null;
+            } else if (pc_ != null) {
+                pc_.removeElement(this);
+                pc_ = null;
+            } else {
+                driver_.weakConnection.removeElement(this);
+                driver_ = null;
+            }
+        }finally {
+            if (JdbcDebugCfg.entryActive)
+            debug[methodId_removeElement_V].methodExit();
+        }
+    }
+
+    /*
+     * RFE: Connection synchronization close() is now synchronized.
+     */
+    synchronized void close(boolean hardClose, boolean sendEvents)
+    throws SQLException {
+        if (JdbcDebugCfg.entryActive)
+        debug[methodId_close_Z].methodEntry(JdbcDebug.debugLevelPooling);
+        if (JdbcDebugCfg.traceActive)
+        debug[methodId_close_Z].methodParameters("hardClose=" + hardClose
+                + ", sendEvents=" + sendEvents);
+        try {
+            clearWarnings();
+
+            if (!hardClose) {
+
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() + "close()"+" Connection logically closed");
+                    out_.println(getTraceId() + "close(hardClose="+hardClose +",sendEvents="+sendEvents+")");
+                }
+                if (isClosed_)
+                return;
+                if (isStatementCachingEnabled()) {
+                    Object[] csArray = null;
+                    csArray = (prepStmtsInCache_.values()).toArray();
+                    closePreparedStatementsAll();
+                    //Venu changed the below line from int to Long for 64 bit
+                    ArrayList<Long> stmtIds = new ArrayList<Long>(
+                            refToStmt_.values());
+                    //Venu changed the below line from Int to Long
+                    ArrayList<Long> listOfStmtsClosed = new ArrayList<Long>();
+                    /*
+                     * List to store the Statement Id Pointer.
+                     */
+                    // venu changed the below line from Int to Long
+                    ArrayList<Long> listOfCachedPrepStmtIds = new ArrayList<Long>();
+                    for (int nfor = 0; nfor < csArray.length; ++nfor) {
+                        listOfCachedPrepStmtIds
+                        .add(((CachedPreparedStatement) csArray[nfor])
+                                .getPstmt_().stmtId_);
+                    }
+                    csArray = null;
+                    for (int i = 0; i < stmtIds.size(); i++) {
+                        /*
+                         * If the Statement is not found in
+                         * CachedPreparedStatements. Then Close it.
+                         */
+                        if (!listOfCachedPrepStmtIds.contains(stmtIds.get(i))) {
+                            try {
+                                // getDialogueId_()
+                                SQLMXStatement.close(server_, getDialogueId_(),
+                                        ((Long) stmtIds.get(i)).intValue(),
+                                        true);
+                            } catch (SQLException se) {
+
+                            }finally {
+                                /*
+                                 * Mark this Statement so that this Statement is
+                                 * removed from the Statement References table.
+                                 */
+                                listOfStmtsClosed.add(stmtIds.get(i));
+                            }
+                        }
+                    }
+                    listOfCachedPrepStmtIds.clear();
+                    /*
+                     * Remove the Statement marked (already closed) from the
+                     * Statement Reference table.
+                     */
+                    Set<WeakReference> ks = refToStmt_.keySet();
+                    Iterator<WeakReference> iter = ks.iterator();
+                    ArrayList<WeakReference> listOfPrefs = new ArrayList<WeakReference>();
+                    int nfor = 0;
+                    while (iter.hasNext()) {
+                        WeakReference pRef = iter.next();
+                        if (listOfStmtsClosed.contains(refToStmt_.get(pRef))) {
+                            listOfPrefs.add(pRef);
+                        }
+                    }
+                    for (nfor = 0; nfor < listOfPrefs.size(); ++nfor) {
+                        refToStmt_.remove(listOfPrefs.get(nfor));
+                    }
+                    listOfPrefs.clear();
+                    /*
+                     * Clear off the Temp list.
+                     */
+                    listOfStmtsClosed.clear();
+                } else {
+                    // close all the statements
+                    //venu changed the below line from Int to Long
+                    ArrayList<Long> stmtIds = new ArrayList<Long>(
+                            refToStmt_.values());
+                    int size = stmtIds.size();
+                    for (int i = 0; i < size; i++) {
+                        try {
+                            SQLMXStatement
+                            .close(server_, getDialogueId_(),
+                                    ((Long) stmtIds.get(i))
+                                    .longValue(), true);
+                        } catch (SQLException se) {
+                            // Ignore any exception and proceed to the next
+                            // statement
+                        }
+                    }
+                    refToStmt_.clear();
+                }
+                // Need to logically close the statement
+                // Rollback the Transaction independent of autoCommit mode
+                if (getTxid_() != 0) {
+                    try {
+                        rollback(server_, getDialogueId_(), getTxid_());
+                    } catch (SQLException se1) {
+                    }
+                    setTxid_(0);
+                }
+                if (this.setOfCQDs.isEmpty() == false) {
+                    if (clearCQD1 == null && clearCQD2 == null
+                            && clearCQD3 == null) {
+                        clearSetOfCQDs(this.getDialogueId_());
+                        clearCQD2 = this
+                        .prepareForResetCQDs("CONTROL TABLE * RESET");
+                        clearSetOfCQDs(this.getDialogueId_());
+                        clearCQD3 = this
+                        .prepareForResetCQDs("CONTROL QUERY SHAPE CUT");
+                        clearSetOfCQDs(this.getDialogueId_());
+                        clearCQD1 = this
+                        .prepareForResetCQDs("CONTROL QUERY DEFAULT * RESET");
+
+                    }
+                    if (clearCQD1 != null) {
+                        clearCQD1.execute();
+                        clearCQD2.execute();
+                        clearCQD3.execute();
+                    }
+                    //native call to clear native cqd list
+                    clearSetOfCQDs(this.getDialogueId_());
+                    this.setOfCQDs.clear();
+                    //to reset all the CQDs required for T2 connection.
+                    connectInitialized_ = false;
+                }
+                pc_.logicalClose(sendEvents);
+                isClosed_ = true;
+            } else {
+
+                if (traceFlag_ >= T2Driver.POOLING_LVL) {
+                    out_.println(getTraceId() +"close()"+" Connection Hard closed");
+                    out_.println(getTraceId() + "close(hardClose="+hardClose +",sendEvents="+sendEvents+")");
+                }
+                if (getDialogueId_() == 0)
+                return;
+                // close all the statements
+                Set<WeakReference> ks1 = refToStmt_.keySet();
+                Iterator<WeakReference> iter1 = ks1.iterator();
+                ArrayList<WeakReference> listOfStmts = new ArrayList<WeakReference> ();
+                while (iter1.hasNext()) {
+                    WeakReference pRef = iter1.next();
+                    listOfStmts.add(pRef);
+                }
+                for(int nfor=0;nfor<listOfStmts.size();nfor++) {
+                    SQLMXStatement st=(SQLMXStatement)(listOfStmts.get(nfor)).get();
+                    if (st != null) {
+                        try {
+                            st.close();
+                        }
+                        catch(SQLException se) {
+                            // Ignore any exception and proceed to the next
+                            // statement
+                        }
+                    }
+                }
+                refToStmt_.clear();
+                // Need to logically close 

<TRUNCATED>


Mime
View raw message