You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by su...@apache.org on 2015/10/10 06:41:55 UTC

[1/6] incubator-trafodion git commit: Delivering multithreaded code to support resultsets.

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master a751675ff -> df76babe9


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafStatement.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafStatement.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafStatement.java
index 484aaba..4fa22d4 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafStatement.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafStatement.java
@@ -28,13 +28,15 @@ import java.io.*;
 import java.nio.*;
 import java.nio.channels.*;
 import java.nio.channels.spi.*;
-//import java.util.*;
+import java.util.*;
 import java.math.BigDecimal;
 import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.concurrent.*;
+//import java.util.HashMap;
+//import java.util.Map;
 
 import org.trafodion.dcs.Constants;
+import org.trafodion.dcs.servermt.ServerConstants;
 import org.trafodion.dcs.util.*;
 import org.trafodion.dcs.servermt.serverDriverInputOutput.*;
 
@@ -45,40 +47,50 @@ public class TrafStatement {
     private static  final Log LOG = LogFactory.getLog(TrafStatement.class);
     private String serverWorkerName = "";
     private String stmtLabel = "";
+    private int stmtHandle = 0;
     private Object stmt = null;
 //    private Statement stmt = null;
 //    private PreparedStatement pstmt = null;
-    private int outNumberParams = 0;
-    private long outParamLength = 0;
-    private Descriptor2List outDescList = null;
-    private Descriptor2List inpDescList = null;
-    private int inpNumberParams = 0;
-    private long inpParamLength = 0;
+    private int paramCount = 0;
+    private long paramLength = 0;
+    private Descriptor2List paramDescList = null;
     private boolean isResultSet = false;
-    private ResultSet rs = null;
+    private boolean isSpj = false;
+    private int sqlStmtType = ServerConstants.TYPE_UNKNOWN;
+// result sets
+    private int resultSetCount;
+    private Integer curKey;
+    private Descriptor2List outDescList;
+    private ConcurrentHashMap<Integer, TrafResultSet> resultSetList = new ConcurrentHashMap<Integer, TrafResultSet>();
 
-    public TrafStatement(String serverWorkerName, String stmtLabel, Connection conn, String sqlString) throws SQLException {
-        if(LOG.isDebugEnabled())
-            LOG.debug(serverWorkerName + ". constructor TrafStatement[" + stmtLabel + "]");
-        this.serverWorkerName = serverWorkerName;
+    private Random random = new Random();
+
+    public TrafStatement(String serverWorkerName, String stmtLabel, Connection conn, String sqlString, int sqlStmtType) throws SQLException {
+        init();
         this.stmtLabel = stmtLabel;
-        setStatement(conn, sqlString);
+        stmtHandle = random.nextInt(1000);
+        stmtHandle = (stmtHandle < 0)? -stmtHandle : stmtHandle;
+        this.serverWorkerName = serverWorkerName;
+        if(LOG.isDebugEnabled())
+            LOG.debug(serverWorkerName + ". constructor TrafStatement[" + stmtLabel + "/" + stmtHandle + "]");
+        setStatement(conn, sqlString, sqlStmtType);
     }
     void init(){
         reset();
     }
     void reset(){
         stmt = null;
-        outNumberParams = 0;
-        outParamLength = 0;
+        paramDescList = null;
+        paramCount = 0;
+        paramLength = 0;
+        resultSetCount = 0;
+        curKey = 0;
         outDescList = null;
-        inpDescList = null;
-        inpNumberParams = 0;
-        inpParamLength = 0;
         isResultSet = false;
-        rs = null;
+        isSpj = false;
+        sqlStmtType = ServerConstants.TYPE_UNKNOWN;
     }
-    public void closeTStatement(){
+    public void closeTStatement() {
         try {
             if (stmt != null){
                 if (stmt instanceof Statement){
@@ -99,56 +111,122 @@ public class TrafStatement {
                 }
             }
         } catch (SQLException sql){}
+        closeAllTResultSets();
         reset();
     }
     public void closeTResultSet(){
         if(LOG.isDebugEnabled())
-            LOG.debug(serverWorkerName + ". T2 rs.close(" + stmtLabel + ") begin");
+            LOG.debug(serverWorkerName + ". TrafStatement closeTResultSet (" + stmtLabel + ")");
         try {
-            if (rs != null && rs.isClosed() == false){
-                if(LOG.isDebugEnabled())
-                    LOG.debug(serverWorkerName + ". T2 rs before close ");
-                rs.close();
-                if(LOG.isDebugEnabled())
-                    LOG.debug(serverWorkerName + ". T2 rs after close ");
-            }
+            if (curKey != 0){
+                resultSetList.get(curKey).closeTResultSet();
+             }
         } catch (Exception e){}
-        rs = null;
-        if(LOG.isDebugEnabled())
-            LOG.debug(serverWorkerName + ". T2 rs.close(" + stmtLabel + ") end");
     }
-    public void setOutNumberParams(int outNumberParams){
-        this.outNumberParams = outNumberParams;
+    public void closeAllTResultSets() {
+        if (LOG.isDebugEnabled())
+            LOG.debug(serverWorkerName + ". closeAllTResultSets resultSetCount : " + resultSetCount);
+        if (resultSetCount != 0){
+            Integer key;
+            Iterator<Integer> keySetIterator = resultSetList.keySet().iterator();
+            while (keySetIterator.hasNext()) {
+                key = keySetIterator.next();
+                resultSetList.get(key).closeTResultSet();
+            }
+            resultSetList.clear();
+        }
+        resultSetCount = 0;
+        curKey = 0;
+    }
+    public boolean getNextTResultSet(){
+        if (LOG.isDebugEnabled())
+            LOG.debug(serverWorkerName + ". getNextTResultSet key :" + (curKey + 1) );
+        Integer key = curKey + 1;
+        if (key <= resultSetCount){
+            if (resultSetList.containsKey(key)){
+                if (LOG.isDebugEnabled())
+                    LOG.debug(serverWorkerName + ". getNextTResultSet returns true ");
+                return true;
+            }
+        }
+        if (LOG.isDebugEnabled())
+            LOG.debug(serverWorkerName + ". getNextTResultSet returns false ");
+        return false;
+    }
+    public void setFirstTResultSet(){
+        if (LOG.isDebugEnabled())
+            LOG.debug(serverWorkerName + ". setFirstTResultSet");
+        curKey = 1;
     }
+    public void addTResultSet(TrafResultSet trs){
+        Integer maxKey = 0;
+        Integer key = 0;
+        Iterator<Integer> keySetIterator = resultSetList.keySet().iterator();
+        while (keySetIterator.hasNext()) {
+            key = keySetIterator.next();
+            if (key > maxKey) maxKey = key;
+        }
+        key = maxKey + 1;
+        resultSetList.put(key, trs);
+        resultSetCount++;
+        curKey = 1;
+        if (LOG.isDebugEnabled())
+            LOG.debug(serverWorkerName + ". addTResultSet key :" + key);
+    }
+//=====================================================
     public void setOutDescList(Descriptor2List outDescList){
         this.outDescList = outDescList;
     }
-    public void setOutParamLength(long outParamLength){
-        this.outParamLength = outParamLength;
+    public void setParamCount(int paramCount){
+        this.paramCount = paramCount;
     }
-    public void setInpNumberParams(int inpNumberParams){
-        this.inpNumberParams = inpNumberParams;
+    public void setParamDescList(Descriptor2List paramDescList){
+        this.paramDescList = paramDescList;
     }
-    public void setInpDescList(Descriptor2List inpDescList){
-        this.inpDescList = inpDescList;
-    }
-    public void setInpParamLength(long inpParamLength){
-        this.inpParamLength = inpParamLength;
+    public void setParamLength(long paramLength){
+        this.paramLength = paramLength;
     }
     public void setIsResultSet(boolean isResultSet){
         this.isResultSet = isResultSet;
     }
-    public void setResultSet(ResultSet rs){
-        this.rs = rs;
+    public void setIsSpj(boolean isSpj){
+        this.isSpj = isSpj;
     }
-    public void setStatement(Connection conn, String sqlString) throws SQLException{
+    public void setStatement(Connection conn, String sqlString, int sqlStmtType) throws SQLException{
         if(LOG.isDebugEnabled())
             LOG.debug(serverWorkerName + ". TrafStatement.setStatement [" + stmtLabel + "]");
         closeTStatement();
+        this.sqlStmtType = sqlStmtType;
+        switch (sqlStmtType){
+            case ServerConstants.TYPE_SELECT:
+            case ServerConstants.TYPE_EXPLAIN:
+            case ServerConstants.TYPE_CATOLOG:
+                isResultSet = true;
+                break;
+            case ServerConstants.TYPE_CALL:
+                isSpj = true;
+            case ServerConstants.TYPE_UPDATE:
+            case ServerConstants.TYPE_DELETE:
+            case ServerConstants.TYPE_INSERT:
+            case ServerConstants.TYPE_INSERT_PARAM:
+            case ServerConstants.TYPE_CREATE:
+            case ServerConstants.TYPE_GRANT:
+            case ServerConstants.TYPE_DROP:
+            case ServerConstants.TYPE_CONTROL:
+                isResultSet = false;
+            default:
+        }
         if (sqlString != null){
-            stmt = conn.prepareStatement(sqlString);
-            if(LOG.isDebugEnabled())
-                LOG.debug(serverWorkerName + ". T2 conn.prepareStatement [" + stmtLabel + "] sqlString :" + sqlString);
+            if (isSpj == true){
+                stmt = conn.prepareCall(sqlString);
+                if(LOG.isDebugEnabled())
+                    LOG.debug(serverWorkerName + ". T2 conn.prepareCall [" + stmtLabel + "] sqlString :" + sqlString);
+            }
+            else {
+                stmt = conn.prepareStatement(sqlString);
+                if(LOG.isDebugEnabled())
+                    LOG.debug(serverWorkerName + ". T2 conn.prepareStatement [" + stmtLabel + "] sqlString :" + sqlString);
+            }
         }
         else {
             this.stmt = conn.createStatement();
@@ -156,6 +234,9 @@ public class TrafStatement {
                 LOG.debug(serverWorkerName + ". T2 conn.createStatement [" + stmtLabel + "]");
         }
     }
+    public void setSqlStmtType(int sqlStmtType){
+        this.sqlStmtType = sqlStmtType;
+    }
 //================================================
     public Object getStatement(){
         return stmt;
@@ -163,25 +244,28 @@ public class TrafStatement {
     public Descriptor2List getOutDescList(){
         return outDescList;
     }
-    public int getOutNumberParams(){
-        return outNumberParams;
-    }
-    public long getOutParamLength(){
-        return outParamLength;
-    }
-    public Descriptor2List getInpDescList(){
-        return inpDescList;
+    public Descriptor2List getParamDescList(){
+        return paramDescList;
     }
-    public int getInpNumberParams(){
-        return inpNumberParams;
+    public int getParamCount(){
+        return paramCount;
     }
-    public long getInpParamLength(){
-        return inpParamLength;
+    public long getParamLength(){
+        return paramLength;
     }
     public boolean getIsResultSet(){
         return isResultSet;
     }
-    public ResultSet getResultSet(){
-        return rs;
+    public boolean getIsSpj(){
+        return isSpj;
+    }
+    public TrafResultSet getTrafResultSet(){
+        return resultSetList.get(curKey);
+    }
+    public int getSqlStmtType(){
+        return sqlStmtType;
+    }
+    public Integer getStmtHandle(){
+        return stmtHandle;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/util/SqlUtils.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/util/SqlUtils.java b/dcs/src/main/java/org/trafodion/dcs/util/SqlUtils.java
index 7d2b63e..e90a301 100644
--- a/dcs/src/main/java/org/trafodion/dcs/util/SqlUtils.java
+++ b/dcs/src/main/java/org/trafodion/dcs/util/SqlUtils.java
@@ -20,7 +20,10 @@ import java.math.BigInteger;
 import java.sql.SQLException;
 import java.sql.Types;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 import java.util.Hashtable;
+import java.util.Arrays;
+import java.io.UnsupportedEncodingException;
 
 import org.trafodion.dcs.Constants;
 import org.trafodion.dcs.servermt.ServerConstants;
@@ -35,7 +38,7 @@ public class SqlUtils {
 
     private SqlUtils() {
     }
-    
+
     static private Hashtable valueToCharset;
     static {
         valueToCharset = new Hashtable(11);
@@ -97,6 +100,63 @@ public class SqlUtils {
         return ret;
     }
 
+    static public String getComponentId(int componentId){
+        String str = "UNKNOWN Component [" + componentId + "]";
+        switch (componentId){
+            case ServerConstants.DCS_MASTER_COMPONENT:
+                str = "DCS_MASTER_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.SQL_COMPONENT:
+                str = "SQL_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.ODBC_SRVR_COMPONENT:
+                str = "ODBC_SRVR_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.DRVR_COMPONENT:
+                str = "DRVR_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.APP_COMPONENT:
+                str = "APP_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.JDBC_DRVR_COMPONENT:
+                str = "JDBC_DRVR_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.LINUX_DRVR_COMPONENT:
+                str = "LINUX_DRVR_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.DOT_NET_DRVR_COMPONENT:
+                str = "DOT_NET_DRVR_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.WIN_UNICODE_DRVR_COMPONENT:
+                str = "WIN_UNICODE_DRVR_COMPONENT [" + componentId + "]";
+                break;
+            case ServerConstants.LINUX_UNICODE_DRVR_COMPONENT:
+                str = "LINUX_UNICODE_DRVR_COMPONENT [" + componentId + "]";
+                break;
+            default:
+        }
+        return str;
+    }
+    static public int getSqlStmtType(int stmtType) {
+        int retQueryType;
+        switch(stmtType){
+            case ServerConstants.TYPE_SELECT:
+                retQueryType = ServerConstants.SQL_SELECT_NON_UNIQUE;
+                break;
+            case ServerConstants.TYPE_UPDATE:
+                retQueryType = ServerConstants.SQL_UPDATE_NON_UNIQUE;
+                break;
+            case ServerConstants.TYPE_DELETE:
+                retQueryType = ServerConstants.SQL_DELETE_NON_UNIQUE;
+                break;
+            case ServerConstants.TYPE_INSERT:
+                retQueryType = ServerConstants.SQL_INSERT_NON_UNIQUE;
+                break;
+            default:
+                retQueryType = stmtType;
+        }
+        return retQueryType;
+    }
     static public short getSqlStmtType(String str) {
         //
         // Kludge to determin if the type of statement.
@@ -120,14 +180,18 @@ public class SqlUtils {
         if ((str3.equals("SELECT")) || (str3.equals("SHOWSHAPE"))
                 || (str3.equals("INVOKE")) || (str3.equals("SHOWCONTROL"))
                 || (str3.equals("SHOWPLAN"))) {
-            rt1 = ServerConstants.TYPE_SELECT;
-        } else if (str3.equals("UPDATE")) {
-                rt1 = ServerConstants.TYPE_UPDATE;
+              rt1 = ServerConstants.SQL_SELECT_NON_UNIQUE;
+//            rt1 = ServerConstants.TYPE_SELECT;
+       } else if (str3.equals("UPDATE")) {
+              rt1 = ServerConstants.SQL_UPDATE_NON_UNIQUE;
+//            rt1 = ServerConstants.TYPE_UPDATE;
         } else if (str3.equals("DELETE")) {
-                rt1 = ServerConstants.TYPE_DELETE;
+              rt1 = ServerConstants.SQL_DELETE_NON_UNIQUE;
+//            rt1 = ServerConstants.TYPE_DELETE;
         } else if (str3.equals("INSERT") || (str.equals("UPSERT"))) {
             if (str.indexOf('?') == -1) {
-                rt1 = ServerConstants.TYPE_INSERT;
+              rt1 = ServerConstants.SQL_INSERT_NON_UNIQUE;
+//            rt1 = ServerConstants.TYPE_INSERT;
             } else {
                 rt1 = ServerConstants.TYPE_INSERT_PARAM;
             }
@@ -151,7 +215,7 @@ public class SqlUtils {
         return rt1;
     }
     static public String getSqlCharsetName(int code) {
-        
+
         String str = ServerConstants.sqlCharsetSTRING_UNKNOWN;
         switch (code){
         case ServerConstants.sqlCharsetCODE_ISO88591:
@@ -171,7 +235,7 @@ public class SqlUtils {
     static public String getSqlError(int retcode)
     {
         String rc;
-        
+
         // SQL_NO_DATA_FOUND can be defined as SQL_NO_DATA
         if (retcode==ServerConstants.SQL_NO_DATA_FOUND)
         {
@@ -241,7 +305,7 @@ public class SqlUtils {
     static public String getSqlStatementType(short stmtType)
     {
         String rc;
-        
+
         if (stmtType == ServerConstants.TYPE_UNKNOWN) return "TYPE_UNKNOWN";
         rc = "";
         if ((stmtType & ServerConstants.TYPE_SELECT) != 0) rc = rc + "|TYPE_SELECT";
@@ -299,7 +363,7 @@ public class SqlUtils {
         }
         return "Unknown (" + stmtType + ")";
     };
-    
+
     static public String getSqlAttrType(int code)
     {
         String rc;
@@ -426,7 +490,7 @@ public class SqlUtils {
     }
     static public BigDecimal getBigDecimalValue(Object paramValue) throws SQLException {
         BigDecimal tmpbd;
-        
+
         if (paramValue instanceof Long) {
             tmpbd = BigDecimal.valueOf(((Long) paramValue).longValue());
         } else if (paramValue instanceof Integer) {
@@ -463,11 +527,11 @@ public class SqlUtils {
         }
         return tmpbd;
     } // end getBigDecimalValue
-    
+
     static public BigDecimal convertSQLBigNumToBigDecimal(ByteBuffer sourceData, int len, int scale, boolean isUnSigned) {
         String strVal = ""; // our final String
         boolean negative = false;
-        
+
         // we need the data in an array which can hold UNSIGNED 16 bit values
         // in java we dont have unsigned datatypes so 32-bit signed is the best
         // we can do
@@ -489,16 +553,16 @@ public class SqlUtils {
             }
             // normally
         }
-        
+
         int curPos = dataInShorts.length - 1; // start at the end
         while (curPos >= 0 && dataInShorts[curPos] == 0)
             // get rid of any trailing 0's
             curPos--;
-        
+
         int remainder = 0;
         long temp; // we need to use a LONG since we will have to hold up to
         // 32-bit UNSIGNED values
-        
+
         // we now have the huge value stored in 2 bytes chunks
         // we will divide by 10000 many times, converting the remainder to
         // String
@@ -516,34 +580,274 @@ public class SqlUtils {
                 temp &= 0xFFFF;
                 temp = temp << 16;
                 temp += dataInShorts[j];
-                
+
                 dataInShorts[j] = (int) (temp / 10000);
                 remainder = (int) (temp % 10000);
             }
-        
+
             // if we are done with the current 16bits, move on
             if (dataInShorts[curPos] == 0)
                 curPos--;
-        
+
             // go through the remainder and add each digit to the final String
             for (int j = 0; j < 4; j++) {
                 strVal = (remainder % 10) + strVal;
                 remainder /= 10;
             }
         }
-        
+
         // when we finish the above loop we still have 1 <10000 value to include
         remainder = dataInShorts[0];
         for (int j = 0; j < 4; j++) {
             strVal = (remainder % 10) + strVal;
             remainder /= 10;
         }
-        
+
         BigInteger bi = new BigInteger(strVal); // create a java BigInt
         if (negative && isUnSigned == false)
             bi = bi.negate();
-        
+
         return new BigDecimal(bi, scale); // create a new BigDecimal with the
         // descriptor's scale
     }
+    static public byte[] formatSqlT4Output(Descriptor2 dsc, byte[] sqlarray, long curOutPos, byte[] outValues, ByteOrder bo) throws UnsupportedEncodingException{
+
+        ByteBuffer bb = null;
+        byte[] dst = null;
+        int len = 0;
+        int offset = 0;
+        int insNull = 0;
+
+        String[] stDate = null;
+        String[] stTime = null;
+        String[] stTimestamp = null;
+        String[] stNanos = null;
+        Integer year = 0;
+        Integer month = 0;
+        Integer day = 0;
+        Integer hour = 0;
+        Integer minutes = 0;
+        Integer seconds = 0;
+        Integer nanos = 0;
+
+        String setString = "";
+        short setShort = 0;
+        int setInt = 0;
+        long setLong = 0L;
+        boolean setSign = false;
+        String charSet = "";
+
+        int precision = dsc.getPrecision();
+        int scale = dsc.getScale();
+        int datetimeCode = dsc.getDatetimeCode();
+        int FSDataType = dsc.getFsDataType();
+        int OdbcDataType = dsc.getOdbcDataType();
+        int dataCharSet = dsc.getSqlCharset();
+        int length = dsc.getMaxLen();
+        int dataType = dsc.getDataType();
+
+        if(dataCharSet == SqlUtils.SQLCHARSETCODE_UNICODE)
+            charSet = "UTF-16LE";
+        else
+            charSet = SqlUtils.getCharsetName(dataCharSet);
+
+        len = sqlarray.length;
+        ByteBuffer tb = ByteBuffer.wrap(sqlarray).order(bo);
+
+        if(LOG.isDebugEnabled())
+            LOG.debug("formatSqlT4Output: -----------");
+
+        switch(dataType){
+        case ServerConstants.SQLTYPECODE_CHAR:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_CHAR :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_VARCHAR:
+        case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_VARCHAR/VARCHAR_LONG :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:       //-601
+            if( length > Short.MAX_VALUE ){
+                len = tb.getInt() + 4;
+            } else {
+                len = tb.getShort() + 2;
+            }
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_VARCHAR :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_DATETIME:
+            LOG.debug("formatSqlT4Output: SQLTYPECODE_DATETIME :" + Arrays.toString(sqlarray));
+            switch(datetimeCode){
+                case ServerConstants.SQLDTCODE_DATE:
+                case ServerConstants.SQLDTCODE_TIME:
+                case ServerConstants.SQLDTCODE_TIMESTAMP:
+                    len = tb.getShort();
+                    dst = new byte[len];
+                    System.arraycopy(sqlarray, 2, dst, 0, len);
+                    setString = new String(dst,"UTF8");
+                    tb.clear();
+                    switch(datetimeCode){
+                        case ServerConstants.SQLDTCODE_DATE:
+                            stDate = setString.split("-");
+                            year = Integer.valueOf(stDate[0]);
+                            month = Integer.valueOf(stDate[1]);
+                            day = Integer.valueOf(stDate[2]);
+                            tb.putShort(year.shortValue());
+                            tb.put(month.byteValue());
+                            tb.put(day.byteValue());
+                            break;
+                        case ServerConstants.SQLDTCODE_TIME:
+                            stTime = setString.split(":");
+                            hour = Integer.valueOf(stTime[0]);
+                            minutes = Integer.valueOf(stTime[1]);
+                            seconds = Integer.valueOf(stTime[2]);
+                            tb.put(hour.byteValue());
+                            tb.put(minutes.byteValue());
+                            tb.put(seconds.byteValue());
+                            break;
+                        case ServerConstants.SQLDTCODE_TIMESTAMP:
+                            stTimestamp = setString.split(" ");
+                            stDate = stTimestamp[0].split("-");
+                            stNanos = stTimestamp[1].split("\\.");
+                            stTime = stNanos[0].split(":");
+                            year = Integer.valueOf(stDate[0]);
+                            month = Integer.valueOf(stDate[1]);
+                            day = Integer.valueOf(stDate[2]);
+                            hour = Integer.valueOf(stTime[0]);
+                            minutes = Integer.valueOf(stTime[1]);
+                            seconds = Integer.valueOf(stTime[2]);
+                            nanos = Integer.valueOf(stNanos[1]);
+                            tb.putShort(year.shortValue());
+                            tb.put(month.byteValue());
+                            tb.put(day.byteValue());
+                            tb.put(hour.byteValue());
+                            tb.put(minutes.byteValue());
+                            tb.put(seconds.byteValue());
+                            tb.putInt(nanos);
+                            break;
+                        case ServerConstants.SQLDTCODE_MPDATETIME:
+                            break;
+                    }
+                default:
+            }
+            break;
+        case ServerConstants.SQLTYPECODE_INTERVAL:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_INTERVAL :" + Arrays.toString(sqlarray));
+            len = tb.getShort();
+            dst = new byte[len];
+            System.arraycopy(sqlarray, 2, dst, 0, len);
+            Arrays.fill(sqlarray, (byte)0);
+            tb.clear();
+            if(dst[0] != '-'){
+                len++;
+                tb.put((byte)' ');
+            }
+            tb.put(dst, 0, dst.length);
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: sqlarray :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_INTEGER:                    //4
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_INTEGER :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_INTEGER_UNSIGNED:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_INTEGER_UNSIGNED :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_SMALLINT:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_SMALLINT :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_SMALLINT_UNSIGNED:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_SMALLINT_UNSIGNED :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_LARGEINT:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_LARGEINT :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_DECIMAL:
+        case ServerConstants.SQLTYPECODE_DECIMAL_UNSIGNED:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_DECIMAL :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_IEEE_REAL:                    //6
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_IEEE_REAL :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_IEEE_FLOAT:                   //7
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_IEEE_FLOAT :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_IEEE_DOUBLE:                  //8
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_IEEE_DOUBLE :" + Arrays.toString(sqlarray));
+            break;
+        case ServerConstants.SQLTYPECODE_NUMERIC:
+        case ServerConstants.SQLTYPECODE_NUMERIC_UNSIGNED:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: SQLTYPECODE_NUMERIC :" + Arrays.toString(sqlarray));
+            switch (len) {
+            case 2:
+                setShort = tb.getShort();
+                setLong = setShort;
+                if(setLong < 0){
+                    setLong = -1L * setLong;
+                    setSign = true;
+                    tb.clear();
+                    tb.put((byte) ((setLong) & 0xff));
+                    tb.put((byte) (((setLong >>> 8) | 0x80) & 0xff));
+                }
+                break;
+            case 4:
+                setInt = tb.getInt();
+                setLong = setInt;
+                if(setLong < 0){
+                    setLong = -1L * setLong;
+                    setSign = true;
+                    tb.clear();
+                    tb.put((byte) ((setLong) & 0xff));
+                    tb.put((byte) ((setLong >>> 8) & 0xff));
+                    tb.put((byte) ((setLong >>> 16) & 0xff));
+                    tb.put((byte) (((setLong >>> 24) | 0x80) & 0xff));
+                }
+                break;
+            case 8:
+                setLong = tb.getLong();
+                if(setLong < 0){
+                    setLong = -1L * setLong;
+                    setSign = true;
+                    tb.clear();
+                    tb.put((byte) ((setLong) & 0xff));
+                    tb.put((byte) ((setLong >>> 8) & 0xff));
+                    tb.put((byte) ((setLong >>> 16) & 0xff));
+                    tb.put((byte) ((setLong >>> 24) & 0xff));
+                    tb.put((byte) ((setLong >>> 32) & 0xff));
+                    tb.put((byte) ((setLong >>> 40) & 0xff));
+                    tb.put((byte) ((setLong >>> 48) & 0xff));
+                    tb.put((byte) (((setLong >>> 56) | 0x80) & 0xff));
+                }
+                break;
+            }
+            break;
+        case ServerConstants.SQLTYPECODE_DECIMAL_LARGE:
+        case ServerConstants.SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
+        case ServerConstants.SQLTYPECODE_BIT:
+        case ServerConstants.SQLTYPECODE_BITVAR:
+        case ServerConstants.SQLTYPECODE_BPINT_UNSIGNED:
+        default:
+            if(LOG.isDebugEnabled())
+                LOG.debug("formatSqlT4Output: default :" + Arrays.toString(sqlarray));
+            break;
+        }
+        if(LOG.isDebugEnabled()){
+            LOG.debug("formatSqlT4Output: offset :" + offset);
+            LOG.debug("formatSqlT4Output: curOutPos :" + curOutPos);
+            LOG.debug("formatSqlT4Output: len :" + len);
+        }
+        System.arraycopy(sqlarray, offset, outValues, (int)curOutPos, len);
+        return outValues;
+    }
 }


[4/6] incubator-trafodion git commit: Delivering multithreaded code to support resultsets.

Posted by su...@apache.org.
Delivering multithreaded code to support resultsets.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/661f4ad8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/661f4ad8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/661f4ad8

Branch: refs/heads/master
Commit: 661f4ad86f0048f55057fbbbe61d7cf686055659
Parents: bd0f69c
Author: Arvind Narain <ar...@dev02.trafodion.org>
Authored: Thu Oct 8 00:19:57 2015 +0000
Committer: Arvind Narain <ar...@dev02.trafodion.org>
Committed: Thu Oct 8 00:19:57 2015 +0000

----------------------------------------------------------------------
 .../trafodion/dcs/servermt/ServerConstants.java |  64 +-
 .../serverDriverInputOutput/Descriptor2.java    | 260 +++---
 .../Descriptor2List.java                        | 269 +++---
 .../SQLWarningOrError.java                      |   7 +-
 .../serverDriverInputOutput/Version.java        |  18 +
 .../serverHandler/ServerApiGetCatalogs.java     | 240 ++++--
 .../serverHandler/ServerApiSqlExecDirect.java   | 182 ++--
 .../serverHandler/ServerApiSqlExecute.java      | 864 ++++++++++++-------
 .../serverHandler/ServerApiSqlFetch.java        | 627 +++++---------
 .../serverHandler/ServerApiSqlPrepare.java      | 207 ++---
 .../ServerApiSqlSetConnectAttr.java             |  39 +-
 .../dcs/servermt/serverSql/TrafConnection.java  | 137 +--
 .../dcs/servermt/serverSql/TrafResultSet.java   | 154 ++++
 .../dcs/servermt/serverSql/TrafStatement.java   | 212 +++--
 .../java/org/trafodion/dcs/util/SqlUtils.java   | 348 +++++++-
 15 files changed, 2102 insertions(+), 1526 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/ServerConstants.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/ServerConstants.java b/dcs/src/main/java/org/trafodion/dcs/servermt/ServerConstants.java
index ae619e9..4284e05 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/ServerConstants.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/ServerConstants.java
@@ -46,7 +46,7 @@ public final class ServerConstants {
 
     public static final char YES                            = 'Y';
     public static final char NO                             = 'N';
-    
+
     public static final int SUCCESS                         =0;
     public static final int FAIL                            =-1;
 
@@ -56,17 +56,26 @@ public final class ServerConstants {
     public static final int BODY_SIZE                       = 1024;
     //
     public static final int SIGNATURE                       = 12345; // 0x3039
-    
+
+    // Literals used in the outContext between Driver and Server
     public static final int DCS_MASTER_COMPONENT            = 2;
+    public static final int SQL_COMPONENT                   = 3;
     public static final int ODBC_SRVR_COMPONENT             = 4;
-    
+    public static final int DRVR_COMPONENT                  = 7;
+    public static final int APP_COMPONENT                   = 8;
+    public static final int JDBC_DRVR_COMPONENT             = 20;
+    public static final int LINUX_DRVR_COMPONENT            = 21;
+    public static final int DOT_NET_DRVR_COMPONENT          = 25;
+    public static final int WIN_UNICODE_DRVR_COMPONENT      = 26;
+    public static final int LINUX_UNICODE_DRVR_COMPONENT    = 27;
+
     public static final int DCS_MASTER_VERSION_MAJOR_1      = 3;
     public static final int DCS_MASTER_VERSION_MINOR_0      = 0;
     public static final int DCS_MASTER_BUILD_1              = 1;
-    
+
     public static final int CHARSET                         = 268435456; //(2^28) For charset changes compatibility
     public static final int PASSWORD_SECURITY               = 67108864; //(2^26)
-    
+
     //=================MXOSRVR versions ===================
     public static final int MXOSRVR_ENDIAN                  = 256;
     public static final int MXOSRVR_VERSION_MAJOR           = 3;
@@ -74,10 +83,10 @@ public final class ServerConstants {
     public static final int MXOSRVR_VERSION_BUILD           = 1;
 
     public static final short DCS_MASTER_GETSRVRAVAILABLE   = 1000 + 19;
-    
+
     public static final String SERVER_NAME                  = "$serverHandler";
     public static final String SERVER_WORKER_NAME           = "$serverWorkerHandler";
-    
+
     public static final int SERVER_STATE_INIT               =0;
     public static final int SERVER_STATE_AVAILABLE          =2;
     public static final int SERVER_STATE_CONNECTING         =3;
@@ -92,7 +101,7 @@ public final class ServerConstants {
     public static final int SERVER_STATE_PORTINUSE          =12;
 
 // All server APIs. Some of them are from AS
-    
+
     public static final int SRVR_API_START=3000;
 
     public static final int SRVR_API_INIT                   =SRVR_API_START;
@@ -142,11 +151,11 @@ public final class ServerConstants {
 
     public static final int SQL_PASSWORD_EXPIRING           = 8857;
     public static final int SQL_PASSWORD_GRACEPERIOD        = 8837;
-    
+
     public static final int SQL_SUCCESS                     = 0; // ODBC Standard
     public static final int SQL_SUCCESS_WITH_INFO           = 1; // ODBC Standard
     public static final int SQL_NO_DATA_FOUND               = 100;
-    public static final int SQL_NO_DATA                     = 100; 
+    public static final int SQL_NO_DATA                     = 100;
     public static final int SQL_ERROR                       = -1;
 //
 //
@@ -197,8 +206,8 @@ public final class ServerConstants {
     public static final int SQLTYPECODE_VARCHAR_WITH_LENGTH    = -601;
     public static final int SQLTYPECODE_VARCHAR_LONG           = -1;
     public static final int SQLTYPECODE_BIT                    = 14;  // not supported
-    public static final int SQLTYPECODE_BITVAR                 = 15;  // not supported 
-    
+    public static final int SQLTYPECODE_BITVAR                 = 15;  // not supported
+
     /* Date/Time/TimeStamp related constants */
     public static final int SQLDTCODE_DATE                     = 1;
     public static final int SQLDTCODE_TIME                     = 2;
@@ -222,7 +231,7 @@ public final class ServerConstants {
     public static final int SQLINTCODE_HOUR_MINUTE             = 11;
     public static final int SQLINTCODE_HOUR_SECOND             = 12;
     public static final int SQLINTCODE_MINUTE_SECOND           = 13;
-    
+
     public static final int SQLDTCODE_YEAR                     = 4;
     public static final int SQLDTCODE_YEAR_TO_MONTH            = 5;
 //    public static final int SQLDTCODE_YEAR_TO_DAY            = 1; //SQL DATE
@@ -254,10 +263,10 @@ public final class ServerConstants {
 
     public static final String CLOB_HEADING            ="JDBC_CLOB_COLUMN -";
     public static final String BLOB_HEADING            ="JDBC_BLOB_COLUMN -";
-    
-    // type codes from SQL/MP include file sql.h, for TYPE_FS descriptor fields 
+
+    // type codes from SQL/MP include file sql.h, for TYPE_FS descriptor fields
     //(with additional SQL/MX datatypes) from sqlcli.h
-    
+
     public static final int SQLDT_16BIT_SIGNED                = 130;
     public static final int SQLDT_16BIT_UNSIGNED              = 131;
     public static final int SQLDT_32BIT_SIGNED                = 132;
@@ -291,11 +300,11 @@ public final class ServerConstants {
     public static final String sqlCharsetSTRING_KSC5601         = "KSC5601";
     public static final String sqlCharsetSTRING_SJIS            = "SJIS";
     public static final String sqlCharsetSTRING_UNICODE         = "UCS2";
-    
+
     public static final int UNKNOWN_DATA_FORMAT                 = 0;
-    public static final int ROWWISE_ROWSETS                     = 1; 
-    public static final int COLUMNWISE_ROWSETS                  = 2;   
-    
+    public static final int ROWWISE_ROWSETS                     = 1;
+    public static final int COLUMNWISE_ROWSETS                  = 2;
+
     public static final int INVALID_SQL_QUERY_STMT_TYPE         = 255;
     public static final int SQL_OTHER                           = -1;
     public static final int SQL_UNKNOWN                         = 0;
@@ -311,7 +320,7 @@ public final class ServerConstants {
     public static final int SQL_SET_TRANSACTION                 = 10;
     public static final int SQL_SET_CATALOG                     = 11;
     public static final int SQL_SET_SCHEMA                      = 12;
-    
+
     public static final short TYPE_UNKNOWN                      = 0;
     public static final short TYPE_SELECT                       = 0x0001;
     public static final short TYPE_UPDATE                       = 0x0002;
@@ -324,10 +333,11 @@ public final class ServerConstants {
     public static final short TYPE_DROP                         = 0x0080;
     public static final short TYPE_CALL                         = 0x0800;
     public static final short TYPE_CONTROL                      = 0x0900;
-    
+    public static final short TYPE_CATOLOG                      = 0x1000;
+
     public static final short TYPE_BLOB                         = 2004;
     public static final short TYPE_CLOB                         = 2005;
-    
+
     public static final int SQL_ATTR_CURSOR_HOLDABLE            = -3;
     public static final int SQL_ATTR_INPUT_ARRAY_MAXSIZE        = -2;
     public static final int SQL_ATTR_QUERY_TYPE                 = -4;
@@ -345,7 +355,7 @@ public final class ServerConstants {
     public static final int SQL_ATTR_PARENT_QID                 = -15;
     public static final int SQL_ATTR_CURSOR_UPDATABLE           = -16;
     public static final int SQL_ATTR_SUBQUERY_TYPE              = -17;
-    
+
     /** shell size in bytes */
     public static final int OBJECT_SHELL_SIZE                   = 8;
     public static final int OBJREF_SIZE                         = 4;
@@ -357,9 +367,9 @@ public final class ServerConstants {
     public static final int BOOLEAN_FIELD_SIZE                  = 1;
     public static final int DOUBLE_FIELD_SIZE                   = 8;
     public static final int FLOAT_FIELD_SIZE                    = 4;
-    
+
     public static final int SERVER_STATUS_DELAY                 = 30000;
-    
+
     // declarations for processing metadata
     public static final short SQL_API_SQLGETTYPEINFO = 47;
     public static final short SQL_API_SQLCOLUMNS = 40;
@@ -395,4 +405,6 @@ public final class ServerConstants {
     // Column types and scopes in SQLSpecialColumns.
     public static final int SQL_BEST_ROWID = 1;
     public static final int SQL_ROWVER = 2;
+
 }
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2.java
index beadf89..e93bab0 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2.java
@@ -68,7 +68,7 @@ public class Descriptor2 {
 //====== Added zo
     private int        odbcPrecision_;
     private int        maxLen_;
-    
+
     private int        displaySize_;
     private String    label_;
 //================== T4 desc fields ============================================
@@ -94,16 +94,14 @@ public class Descriptor2 {
     private int     intLeadPrec;
     private int     paramMode;
 // temp values
-    private long     memAlignOffset;
-    private int     allocSize;
-    private int     varLayout;
-    
+    private long varLength;
+
     public Descriptor2(int sqlCharset_, int odbcCharset_, int sqlDataType_, int dataType_, short sqlPrecision_, short sqlDatetimeCode_,
             int sqlOctetLength_,int isNullable_,String name_,int scale_,int precision_,boolean isSigned_,
             boolean isCurrency_,boolean isCaseSensitive_,String catalogName_,String schemaName_,String tableName_,
             int fsDataType_,int intLeadPrec_,int paramMode_,int paramIndex_,int paramPos_,int odbcPrecision_,
-            int maxLen_,int displaySize_,String label_, boolean oldFormat){
-        
+            int maxLen_,int displaySize_,String label_, boolean oldFormat) {
+
         this.oldFormat = oldFormat;
         this.sqlCharset_ = sqlCharset_;
         this.odbcCharset_ = odbcCharset_;
@@ -135,7 +133,7 @@ public class Descriptor2 {
         this.displaySize_ = displaySize_;
         this.label_ = label_;
 //====================================================================
-        if(LOG.isDebugEnabled()){
+        if(LOG.isDebugEnabled()) {
             LOG.debug("T2 descriptor ----------");
             LOG.debug("Old Format       :" + oldFormat);
             LOG.debug("sqlCharset_      :" + sqlCharset_);
@@ -207,12 +205,12 @@ public class Descriptor2 {
                     break;
                 case 134:
                     dataType = ServerConstants.SQLTYPECODE_LARGEINT;
-                    break;                              
+                    break;
                 default:
                     break;
             }
         }
-        switch(odbcDataType){
+        switch(odbcDataType) {
             case Types.DATE:
                 odbcDataType = 9;
                 break;
@@ -225,12 +223,10 @@ public class Descriptor2 {
                 precision = odbcPrecision;
                 break;
         }
-//================================================================        
-        memAlignOffset = 0;
-        allocSize = 0;
-        varLayout = 0;
-        
-        if(LOG.isDebugEnabled()){
+//================================================================
+        varLength = 0;
+
+        if(LOG.isDebugEnabled()) {
             LOG.debug("T4 descriptor ----------");
             LOG.debug("noNullValue      :" + noNullValue);
             LOG.debug("nullValue        :" + nullValue);
@@ -252,14 +248,12 @@ public class Descriptor2 {
             LOG.debug("headingName      :" + headingName);
             LOG.debug("intLeadPrec      :" + intLeadPrec);
             LOG.debug("paramMode        :" + paramMode);
-            LOG.debug("memAlignOffset   :" + memAlignOffset);
-            LOG.debug("allocSize        :" + allocSize);
-            LOG.debug("varLayout        :" + varLayout);
+            LOG.debug("varLength        :" + varLength);
             LOG.debug("T4 descriptor End ----------");
         }
     }
 //==========================================================================
-    public Descriptor2(Descriptor2 dsc){
+    public Descriptor2(Descriptor2 dsc) {
         this.oldFormat = dsc.oldFormat;
         this.sqlCharset_ = dsc.sqlCharset_;
         this.odbcCharset_ = dsc.odbcCharset_;
@@ -309,14 +303,12 @@ public class Descriptor2 {
         this.headingName = dsc.headingName;
         this.intLeadPrec = dsc.intLeadPrec;
         this.paramMode = dsc.paramMode;
-        
-        memAlignOffset = 0;
-        allocSize = 0;
-        varLayout = 0;
-        
+
+        varLength = 0;
+
     }
     public void insertIntoByteBuffer(ByteBuffer bbBuf) throws UnsupportedEncodingException {
-        if (oldFormat == false){
+        if (oldFormat == false) {
             bbBuf.putInt(noNullValue);
             bbBuf.putInt(nullValue);
             bbBuf.putInt(version);
@@ -363,8 +355,8 @@ public class Descriptor2 {
     }
     public int lengthOfData() {
         int datamaxLen = 0;
-        
-        if (oldFormat == false){
+
+        if (oldFormat == false) {
             datamaxLen += ServerConstants.INT_FIELD_SIZE;
             datamaxLen += ServerConstants.INT_FIELD_SIZE;
             datamaxLen += ServerConstants.INT_FIELD_SIZE;
@@ -392,13 +384,13 @@ public class Descriptor2 {
             datamaxLen += ServerConstants.INT_FIELD_SIZE;       //dataType
             datamaxLen += ServerConstants.INT_FIELD_SIZE;       //datetimeCode
             datamaxLen += ServerConstants.INT_FIELD_SIZE;       //maxLen
-            datamaxLen += ServerConstants.SHORT_FIELD_SIZE;       //precision
-            datamaxLen += ServerConstants.SHORT_FIELD_SIZE;       //scale
-            datamaxLen += ServerConstants.BYTE_FIELD_SIZE;       //nullInfo
+            datamaxLen += ServerConstants.SHORT_FIELD_SIZE;     //precision
+            datamaxLen += ServerConstants.SHORT_FIELD_SIZE;     //scale
+            datamaxLen += ServerConstants.BYTE_FIELD_SIZE;      //nullInfo
             datamaxLen += ByteBufferUtils.lengthOfString(colHeadingNm);
-            datamaxLen += ServerConstants.BYTE_FIELD_SIZE;       //signed
+            datamaxLen += ServerConstants.BYTE_FIELD_SIZE;      //signed
             datamaxLen += ServerConstants.INT_FIELD_SIZE;       //odbcDataType
-            datamaxLen += ServerConstants.SHORT_FIELD_SIZE;       //odbcPrecision
+            datamaxLen += ServerConstants.SHORT_FIELD_SIZE;     //odbcPrecision
             datamaxLen += ServerConstants.INT_FIELD_SIZE;       //sqlCharset
             datamaxLen += ServerConstants.INT_FIELD_SIZE;       //odbcCharset
             datamaxLen += ByteBufferUtils.lengthOfString(tableName);
@@ -410,165 +402,151 @@ public class Descriptor2 {
         }
         return datamaxLen;
     }
-    public void setOldFormat(boolean oldFormat){
+    public void setOldFormat(boolean oldFormat) {
         this.oldFormat = oldFormat;
     }
-    public boolean getOldFormat(){
+    public boolean getOldFormat() {
         return oldFormat;
     }
-    public void setNoNullValue(int v){
+    public void setNoNullValue(int v) {
         noNullValue = v;
     }
-    public void setNullValue(int v){
-        nullValue = v;        
-    }
-    public void setVersion(int v){
-        version = v;         
-    }
-    public void setDataType(int v){
-        dataType = v;         
+    public void setNullValue(int v) {
+        nullValue = v;
     }
-    public void setDatetimeCode(int v){
-        datetimeCode = v;         
+    public void setVersion(int v) {
+        version = v;
     }
-    public void setMaxLen(int v){
-        maxLen = v;         
+    public void setDataType(int v) {
+        dataType = v;
     }
-    public void setPrecision(int v){
-        precision = v;         
+    public void setDatetimeCode(int v) {
+        datetimeCode = v;
     }
-    public void setScale(int v){
-        scale = v;         
+    public void setMaxLen(int v) {
+        maxLen = v;
     }
-    public void setNullInfo(int v){
-        nullInfo = v;         
+    public void setPrecision(int v) {
+        precision = v;
     }
-    public void setSigned(int v){
-        signed = v;         
+    public void setScale(int v) {
+        scale = v;
     }
-    public void setOdbcDataType(int v){
-        odbcDataType = v;        
+    public void setNullInfo(int v) {
+        nullInfo = v;
     }
-    public void setOdbcPrecision(int v){
-        odbcPrecision = v;        
+    public void setSigned(int v) {
+        signed = v;
     }
-    public void setSqlCharset(int v){
-        sqlCharset = v;         
+    public void setOdbcDataType(int v) {
+        odbcDataType = v;
     }
-    public void setOdbcCharset(int v){
-        odbcCharset = v;        
+    public void setOdbcPrecision(int v) {
+        odbcPrecision = v;
     }
-    public void setColHeadingNm(String v){
-        colHeadingNm = v;         
+    public void setSqlCharset(int v) {
+        sqlCharset = v;
     }
-    public void setTableName(String v){
-        tableName = v;         
+    public void setOdbcCharset(int v) {
+        odbcCharset = v;
     }
-    public void setCatalogName(String v){
-        catalogName = v;         
+    public void setColHeadingNm(String v) {
+        colHeadingNm = v;
     }
-    public void setSchemaName(String v){
-        schemaName = v;         
+    public void setTableName(String v) {
+        tableName = v;
     }
-    public void setHeadingName(String v){
-        headingName = v;         
+    public void setCatalogName(String v) {
+        catalogName = v;
     }
-    public void setIntLeadPrec(int v){
-        intLeadPrec = v;         
+    public void setSchemaName(String v) {
+        schemaName = v;
     }
-    public void setParamMode(int v){
-        paramMode = v;        
+    public void setHeadingName(String v) {
+        headingName = v;
     }
-//--------------------------------
-    public void setMemAlignOffset(long memAlignOffset){
-        this.memAlignOffset = memAlignOffset;
+    public void setIntLeadPrec(int v) {
+        intLeadPrec = v;
     }
-    public void setAllocSize(int allocSize){
-        this.allocSize = allocSize;
+    public void setParamMode(int v) {
+        paramMode = v;
     }
-    public void setVarLayout(int varLayout){
-        this.varLayout = varLayout;
+    public void setVarLength(long varLength) {
+        this.varLength = varLength;
     }
+
 //-----------------------------
-    public int getNoNullValue(){
+    public int getNoNullValue() {
         return noNullValue;
     }
-    public int getNullValue(){
-        return nullValue;        
-    }
-    public int getVersion(){
-        return version;        
+    public int getNullValue() {
+        return nullValue;
     }
-    public int getDataType(){
-        return dataType;        
+    public int getVersion() {
+        return version;
     }
-    public int getDatetimeCode(){
-        return datetimeCode;        
+    public int getDataType() {
+        return dataType;
     }
-    public int getMaxLen(){
-        return maxLen;        
+    public int getDatetimeCode() {
+        return datetimeCode;
     }
-    public int getPrecision(){
-        return precision;        
+    public int getMaxLen() {
+        return maxLen;
     }
-    public int getScale(){
-        return scale;        
+    public int getPrecision() {
+        return precision;
     }
-    public int getNullInfo(){
-        return nullInfo;        
+    public int getScale() {
+        return scale;
     }
-    public int getSigned(){
-        return signed;        
+    public int getNullInfo() {
+        return nullInfo;
     }
-    public int getOdbcDataType(){
-        return odbcDataType;        
+    public int getSigned() {
+        return signed;
     }
-    public int getOdbcPrecision(){
-        return odbcPrecision;        
+    public int getOdbcDataType() {
+        return odbcDataType;
     }
-    public int getSqlCharset(){
-        return sqlCharset;        
+    public int getOdbcPrecision() {
+        return odbcPrecision;
     }
-    public int getOdbcCharset(){
-        return odbcCharset;        
+    public int getSqlCharset() {
+        return sqlCharset;
     }
-    public String getColHeadingNm(){
-        return colHeadingNm;        
+    public int getOdbcCharset() {
+        return odbcCharset;
     }
-    public String getTableName(){
-        return tableName;        
+    public String getColHeadingNm() {
+        return colHeadingNm;
     }
-    public String getCatalogName(){
-        return catalogName;        
+    public String getTableName() {
+        return tableName;
     }
-    public String getSchemaName(){
-        return schemaName;        
+    public String getCatalogName() {
+        return catalogName;
     }
-    public String getHeadingName(){
-        return headingName;        
+    public String getSchemaName() {
+        return schemaName;
     }
-    public int getIntLeadPrec(){
-        return intLeadPrec;        
+    public String getHeadingName() {
+        return headingName;
     }
-    public int getParamMode(){
-        return paramMode;        
+    public int getIntLeadPrec() {
+        return intLeadPrec;
     }
-//--------------------------------
-    public long getMemAlignOffset(){
-        return memAlignOffset;
+    public int getParamMode() {
+        return paramMode;
     }
-    public int getAllocSize(){
-        return allocSize;
-    }
-    public int getVarLayout(){
-        return varLayout;
-    }
-//-----------------------------
-    public int getFsDataType(){
+    public int getFsDataType() {
         return fsDataType_;
     }
+    public long getVarLength() {
+        return varLength;
+    }
 //-----------------------------
-    public void debugDescriptor(){
+    public void debugDescriptor() {
         if(LOG.isDebugEnabled()){
             LOG.debug("T4 descriptor -----------");
             LOG.debug("Old Format       :" + oldFormat);
@@ -593,9 +571,7 @@ public class Descriptor2 {
             LOG.debug("headingName      :" + headingName);
             LOG.debug("intLeadPrec      :" + intLeadPrec);
             LOG.debug("paramMode        :" + paramMode);
-            LOG.debug("memAlignOffset   :" + memAlignOffset);
-            LOG.debug("allocSize        :" + allocSize);
-            LOG.debug("varLayout        :" + varLayout);
+            LOG.debug("varLength        :" + varLength);
             LOG.debug("T4 descriptor End -----------");
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2List.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2List.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2List.java
index b5a07bd..df8c749 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2List.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Descriptor2List.java
@@ -42,119 +42,103 @@ import org.apache.commons.logging.LogFactory;
 
 public class Descriptor2List {
     private static  final Log LOG = LogFactory.getLog(Descriptor2List.class);
-    private int length;
-    private long paramLength;
-    private long nullLength;
-    private long noNullLength;
-    private int numberParams;
+    private long varLength;
+    private int descLength;
+    private int descCount;
     private Descriptor2[] buffer;
     private boolean oldFormat;
-    private int lengthOldFormat;        //for Catalogs Api we need to convert Descriptor2 to Old Format
-    
+
     public Descriptor2List(){
-        length = 0;
-        paramLength = 0;
-        numberParams = 0; 
+        varLength = 0;
+        descLength = 0;
+        descCount = 0;
         buffer = null;
         oldFormat = false;
-        lengthOldFormat = 0;
     }
-    public Descriptor2List(int numberParams, boolean oldFormat){
+    public Descriptor2List(int descCount, boolean oldFormat){
+        this.varLength = 0;
+        this.descLength = 0;
+        this.descCount = descCount;
         this.oldFormat = oldFormat;
-        lengthOldFormat = ServerConstants.INT_FIELD_SIZE; //old SQLItemDescList
-        this.length = 3 * ServerConstants.INT_FIELD_SIZE;
-        this.paramLength = 0;
-        this.nullLength = 0;        //length of null buffer. every description needs short 
-        this.noNullLength = 0;        //length of nonull buffer. 
-        this.numberParams = numberParams; 
-        buffer = new Descriptor2[numberParams];
+        buffer = new Descriptor2[descCount];
     }
     public Descriptor2List(Descriptor2List dl){
+        descLength = dl.descLength;
+        varLength = dl.varLength;
+        descCount = dl.descCount;
         oldFormat = dl.oldFormat;
-        lengthOldFormat = dl.lengthOldFormat;
-        length = dl.length;
-        paramLength = dl.paramLength;
-        nullLength = dl.nullLength;
-        noNullLength = dl.noNullLength;
-        numberParams = dl.numberParams;
-        buffer = new Descriptor2[numberParams];
-        for (int i = 0; i < numberParams; i++)
+        buffer = new Descriptor2[descCount];
+        for (int i = 0; i < descCount; i++)
             buffer[i] = dl.buffer[i];
     }
-    public void addDescriptor(int param, Descriptor2 dsc){
+    public void addDescriptor(int descNumber, Descriptor2 dsc){
+
         if(LOG.isDebugEnabled())
-            LOG.debug("addDescriptor param :" + param + " numberParams :" + numberParams);
-        length += dsc.lengthOfData();
-        if (dsc.getNullInfo() == 1){        //nullable
-            dsc.setNullValue((int)nullLength);
-            nullLength += 2;
-        }
-        else {
-            dsc.setNullValue(-1);            //nonullable
-        }
-        dsc = getMemoryAllocInfo(dsc, noNullLength);
-        noNullLength += dsc.getMemAlignOffset();
-        noNullLength = ((noNullLength + 2 - 1) >> 1) << 1;
-        noNullLength += ServerConstants.SHORT_FIELD_SIZE;
-        dsc.setNoNullValue((int)noNullLength);
-        buffer[param - 1] = dsc;
-        
-        noNullLength += dsc.getAllocSize();
-        if (numberParams == param){
-            Descriptor2 tmpdsc = null;
-            long tmpNoNullLength = 0;
-            
-            nullLength = ((nullLength + 8 - 1) >> 3) << 3;
-            noNullLength = ((noNullLength + 8 - 1) >> 3) << 3;
-            paramLength = nullLength + noNullLength;
-            if(LOG.isDebugEnabled()){
-                LOG.debug("nullLength :" + nullLength);
-                LOG.debug("noNullLength :" + noNullLength);
-                LOG.debug("maxLen :" + paramLength);
-            }
-            for (int i = 0; i < numberParams; i++) {
-                tmpdsc = buffer[i];
-                tmpNoNullLength = tmpdsc.getNoNullValue();
-                tmpdsc.setNoNullValue((int)(nullLength + tmpNoNullLength));
-                buffer[i] = tmpdsc;
+            LOG.debug("addDescriptor descNumber :" + descNumber + " descCount :" + descCount);
+        buffer[descNumber - 1] = dsc;
+
+        if (descCount == descNumber){
+            Descriptor2 desc = null;
+            if (oldFormat == false)
+                descLength = 3 * ServerConstants.INT_FIELD_SIZE;
+            else
+                descLength = ServerConstants.INT_FIELD_SIZE;
+            varLength = 0;
+
+            for (int i = 0; i < descCount; i++) {
+                desc = buffer[i];
+                descLength += desc.lengthOfData();
+
+                if (oldFormat == false){
+                    if (desc.getNullInfo() == 1){        //nullable
+                        varLength = ((varLength + 2 - 1) >> 1) << 1;
+                        desc.setNullValue((int)varLength);
+                        varLength += 2;
+                    }
+                    else {
+                        desc.setNullValue(-1);            //nonullable
+                    }
+                    desc = setVarLength(desc, varLength);
+                    varLength = desc.getVarLength();
+                } else {
+                    desc = setVarLength(desc, varLength);
+                    varLength = desc.getVarLength();
+                }
                 if(LOG.isDebugEnabled()){
-                    LOG.debug("param :" + (i+1));
-                    LOG.debug("noNullValue :" + tmpdsc.getNoNullValue());
-                    LOG.debug("nullValue :" + tmpdsc.getNullValue());
-                    LOG.debug("maxLen :" + tmpdsc.getMaxLen());
+                   LOG.debug("--------desc :" + (i+1));
+                   LOG.debug("varLength :" + varLength);
+                   LOG.debug("noNullValue :" + desc.getNoNullValue());
+                   LOG.debug("nullValue :" + desc.getNullValue());
+                   LOG.debug("maxLen :" + desc.getMaxLen());
                 }
+                buffer[i] = desc;
             }
         }
     }
     public void insertIntoByteBuffer(ByteBuffer bbBuf) throws UnsupportedEncodingException {
         if (oldFormat == false){
-            if(LOG.isDebugEnabled())
-                LOG.debug("length :" + length + " paramLength :" + paramLength + " numberParams :" + numberParams);
-            bbBuf.putInt(length);
-            if (length > 0){
-                bbBuf.putInt((int)paramLength);
-                bbBuf.putInt(numberParams);
-                for (int i = 0; i < numberParams; i++) {
+            bbBuf.putInt(descLength);
+            if (descLength > 0){
+                bbBuf.putInt((int)varLength);          // param length
+                bbBuf.putInt(descCount);                // param count
+                for (int i = 0; i < descCount; i++) {
                     buffer[i].insertIntoByteBuffer(bbBuf);
                 }
             }
          }
         else {
             if(LOG.isDebugEnabled())
-                 LOG.debug("numberParams :" + numberParams);
-            bbBuf.putInt(numberParams);
-            if (numberParams > 0){
-                for (int i = 0; i < numberParams; i++) {
+                 LOG.debug("descCount :" + descCount);
+            bbBuf.putInt(descCount);
+            if (descCount > 0){
+                for (int i = 0; i < descCount; i++) {
                     buffer[i].insertIntoByteBuffer(bbBuf);
                 }
             }
         }
     }
     public int lengthOfData() {
-        if (oldFormat == false)
-            return length;        
-        else
-            return lengthOldFormat;
+        return descLength;
     }
     public void setOldFormat(boolean oldFormat){
         this.oldFormat = oldFormat;
@@ -162,100 +146,105 @@ public class Descriptor2List {
     public boolean getOldFormat(){
         return oldFormat;
     }
-    public void  setParamLength(long paramLength){
-        this.paramLength = paramLength;
+    public void  setDescLength(int descLength){
+        this.descLength = descLength;
     }
     public Descriptor2[] getDescriptors2(){
         return buffer;
     }
-    public int getLength(){
-        return length;
+    public long getVarLength(){
+        return varLength;
     }
-    public long getParamLength(){
-        return paramLength;
+    public int getDescLength(){
+        return descLength;
     }
-    public int getNumberParams(){
-        return numberParams;
+    public int getDescCount(){
+        return descCount;
     }
-//    
-// Compute the memory allocation requirements for the descriptor data type
-//   
-    Descriptor2 getMemoryAllocInfo(Descriptor2 desc, long currMemOffset) {
+    Descriptor2 setVarLength(Descriptor2 desc, long memOffSet) {
         int dataType = desc.getDataType();
         int dataLength = desc.getMaxLen();
-        int charSet = desc.getSqlCharset();
-//
-        int varPad = 0;            // Bytes to pad allocation for actual data type memory requirements
-        int varNulls = 0;        // Number of extra bytes that will be appended to data type (e.g. NULL for strings)
-        long memAlignOffset = 0;    // Boundry offset from current memory location to set the data pointer
-        int allocBoundry = 0;    // Boundry to round the size of the memory allocation to end on proper boundry
-        int allocSize = 0;
-        int varLayout = 0;
 
         switch (dataType)
         {
         case ServerConstants.SQLTYPECODE_CHAR:
         case ServerConstants.SQLTYPECODE_VARCHAR:
-            if( charSet == ServerConstants.sqlCharsetCODE_ISO88591 )
-                varNulls = 1;
+            desc.setNoNullValue((int)memOffSet);
+            memOffSet += dataLength;
             break;
         case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:
+            if( dataLength > Short.MAX_VALUE )
+            {
+                if (oldFormat == false){
+                    memOffSet = ((memOffSet + 4 - 1) >> 2) << 2;
+                    desc.setNoNullValue((int)memOffSet);
+                }
+                memOffSet += dataLength + 4;
+            }
+            else
+            {
+                if (oldFormat == false){
+                    memOffSet = ((memOffSet + 2 - 1) >> 1) << 1;
+                    desc.setNoNullValue((int)memOffSet);
+                }
+                memOffSet += dataLength + 2;
+            }
+            break;
         case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
-            memAlignOffset = (((currMemOffset + 2 - 1) >> 1) << 1) - currMemOffset;
-            varPad = 2;
-            varNulls = 1;
-            allocBoundry = 2;
+            if (oldFormat == false){
+                memOffSet = ((memOffSet + 2 - 1) >> 1) << 1;
+                desc.setNoNullValue((int)memOffSet);
+            }
+            memOffSet += dataLength + 2;
             break;
         case ServerConstants.SQLTYPECODE_SMALLINT:
         case ServerConstants.SQLTYPECODE_SMALLINT_UNSIGNED:
-            memAlignOffset = (((currMemOffset + 2 - 1) >> 1) << 1) - currMemOffset;
+            if (oldFormat == false){
+                memOffSet = ((memOffSet + 2 - 1) >> 1) << 1;
+                desc.setNoNullValue((int)memOffSet);
+            }
+            memOffSet += dataLength;
             break;
         case ServerConstants.SQLTYPECODE_INTEGER:
         case ServerConstants.SQLTYPECODE_INTEGER_UNSIGNED:
-            memAlignOffset = (((currMemOffset + 4 - 1) >> 2) << 2) - currMemOffset;
+        //case SQLTYPECODE_IEEE_REAL:
+            if (oldFormat == false){
+                memOffSet = ((memOffSet + 4 - 1) >> 2) << 2;
+                desc.setNoNullValue((int)memOffSet);
+            }
+            memOffSet += dataLength;
             break;
         case ServerConstants.SQLTYPECODE_LARGEINT:
-        case ServerConstants.SQLTYPECODE_REAL:
-        case ServerConstants.SQLTYPECODE_DOUBLE:
-            memAlignOffset = (((currMemOffset + 8 - 1) >> 3) << 3) - currMemOffset;
+        case ServerConstants.SQLTYPECODE_IEEE_REAL:
+        case ServerConstants.SQLTYPECODE_IEEE_FLOAT:
+        case ServerConstants.SQLTYPECODE_IEEE_DOUBLE:
+            if (oldFormat == false){
+                memOffSet = ((memOffSet + 8 - 1) >> 3) << 3;
+                desc.setNoNullValue((int)memOffSet);
+            }
+            memOffSet += dataLength;
             break;
         case ServerConstants.SQLTYPECODE_DECIMAL_UNSIGNED:
         case ServerConstants.SQLTYPECODE_DECIMAL:
         case ServerConstants.SQLTYPECODE_DECIMAL_LARGE_UNSIGNED: // Tandem extension
         case ServerConstants.SQLTYPECODE_DECIMAL_LARGE: // Tandem extension
-            break;
-        case ServerConstants.SQLTYPECODE_INTERVAL:        // Treating as CHAR
+        case ServerConstants.SQLTYPECODE_INTERVAL:      // Treating as CHAR
         case ServerConstants.SQLTYPECODE_DATETIME:
-            memAlignOffset = (((currMemOffset + 2 - 1) >> 1) << 1) - currMemOffset;
-            varPad = 2;
-            varNulls = 1;
-            allocBoundry = 2;
+            if (oldFormat == false){
+                desc.setNoNullValue((int)memOffSet);
+            }
+            memOffSet += dataLength;
             break;
         default:
-            memAlignOffset = (((currMemOffset + 8 - 1) >> 3) << 3) - currMemOffset;
+            if (oldFormat == false){
+                memOffSet = ((memOffSet + 8 - 1) >> 3) << 3;
+                desc.setNoNullValue((int)memOffSet);
+            }
+            memOffSet += dataLength;
             break;
         }
-        varLayout = dataLength + varNulls;
-        allocSize = varLayout + varPad;
-        if (allocBoundry != 0) allocSize += allocSize % allocBoundry;
-        
-        desc.setMemAlignOffset(memAlignOffset);
-        desc.setAllocSize(allocSize);
-        desc.setVarLayout(varLayout);
-
-        if(LOG.isDebugEnabled()){
-            LOG.debug("input currMemOffset :" + currMemOffset);
-            LOG.debug("input dataType :" + SqlUtils.getSqlDataType(dataType) + " [" + dataType + "]" );
-            LOG.debug("input dataLength :" + dataLength);
-            LOG.debug("input SqlCharsetSTRING :" + SqlUtils.getCharsetName(charSet) + " [" + charSet + "]");
-            LOG.debug("tmp varNulls :" + varNulls);
-            LOG.debug("tmp varPad :" + varPad);
-            LOG.debug("tmp allocBoundry :" + allocBoundry);
-            LOG.debug("output memAlignOffset :" + memAlignOffset);
-            LOG.debug("output allocSize :" + allocSize);
-            LOG.debug("output varLayout :" + varLayout);
-        }
-
+        desc.setVarLength(memOffSet);
         return desc;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/SQLWarningOrError.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/SQLWarningOrError.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/SQLWarningOrError.java
index 9be219b..7c0ebc0 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/SQLWarningOrError.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/SQLWarningOrError.java
@@ -52,7 +52,7 @@ public class SQLWarningOrError {
         sqlState = "";
     }
     public SQLWarningOrError(SQLException ex, int rowId) {
-        
+
         this.rowId = rowId;
         sqlCode = ex.getErrorCode();
         text = ex.getMessage();
@@ -74,12 +74,13 @@ public class SQLWarningOrError {
         bbBuf.putInt(rowId);
         bbBuf.putInt(sqlCode);
         ByteBufferUtils.insertString(text,bbBuf);
+        sqlState = (sqlState == null)? "HY024" : sqlState;
         bbBuf.put(sqlState.getBytes(),0,5);
         bbBuf.put((byte)0); //null terminator
     }
     public int lengthOfData() {
         int dataLength = 0;
-        
+
         dataLength += ServerConstants.INT_FIELD_SIZE;         //rowId
         dataLength += ServerConstants.INT_FIELD_SIZE;         //sqlcode
         dataLength += ByteBufferUtils.lengthOfString(text);
@@ -98,7 +99,7 @@ public class SQLWarningOrError {
     public String getSqlState(){
         return sqlState;
     }
-    
+
     public void setRowId(int rowId){
         this.rowId = rowId;
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Version.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Version.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Version.java
index b9eb4b0..aa29f16 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Version.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverDriverInputOutput/Version.java
@@ -87,4 +87,22 @@ public class Version {
     public void setBuildId( int buildId){
         this.buildId = buildId;
     }
+    public short getComponentId(){
+        return componentId;
+    }
+    public short getMajorVersion(){
+        return majorVersion;
+    }
+    public short getMinorVersion(){
+        return minorVersion;
+    }
+    public int getBuildId(){
+        return buildId;
+    }
+    public void debug(){
+        LOG.debug("version componentId  : " + SqlUtils.getComponentId(componentId));
+        LOG.debug("version majorVersion : " + majorVersion);
+        LOG.debug("version minorVersion : " + minorVersion);
+        LOG.debug("version buildId      : " + buildId);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
index 18895a5..86a5515 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
@@ -55,17 +55,18 @@ public class ServerApiGetCatalogs {
     private ClientData clientData;
     private TrafConnection trafConn;
     private TrafStatement trafStmt;
+    private boolean oldFormat;
 
-    private Descriptor2List resultSetDescList;
+    private Descriptor2List outDescList;
     private DatabaseMetaData dbmd;
     private ResultSet rs;
     private ResultSetMetaData rsmd;
     private TResultSetMetaData trsmd;
     private SQLMXResultSetMetaData strsmd;
     private String proxySyntax;
-    private int numResultSets;
-    private int resultSetColumns;
-    
+    private int resultSetCount;
+    private int outCount;
+
     private int dialogueId;
     private String stmtLabel;
     private short APIType;
@@ -84,14 +85,14 @@ public class ServerApiGetCatalogs {
     private String fkCatalogNm;
     private String fkSchemaNm;
     private String fkTableNm;
-    
+
     //-------------T2 desc fields-------------------
     private int sqlCharset_;
     private int odbcCharset_;
     private int sqlDataType_;
     private int dataType_;
-    private short   sqlPrecision_;
-    private short   sqlDatetimeCode_;
+    private short sqlPrecision_;
+    private short sqlDatetimeCode_;
     private int sqlOctetLength_;
     private int isNullable_;
     private String  name_;
@@ -108,18 +109,18 @@ public class ServerApiGetCatalogs {
     private int paramMode_;
     private int paramIndex_;
     private int paramPos_;
-    
+
     private int odbcPrecision_;
     private int  maxLen_;
 
     private int displaySize_;
     private String label_;
-    
+
     private SQLWarningOrErrorList errorList = null;
-    
+
     private ServerException serverException;
 
-    ServerApiGetCatalogs(int instance, int serverThread) {  
+    ServerApiGetCatalogs(int instance, int serverThread) {
         this.instance = instance;
         this.serverThread = serverThread;
         serverWorkerName = ServerConstants.SERVER_WORKER_NAME + "_" + instance + "_" + serverThread;
@@ -131,13 +132,16 @@ public class ServerApiGetCatalogs {
     void reset(){
         trafConn = null;
         trafStmt = null;
+        oldFormat = false;
         dbmd = null;
-        resultSetDescList = null;
+        outDescList = null;
+        outCount = 0;
+        resultSetCount = 0;
         rs = null;
         rsmd = null;
         trsmd = null;
         strsmd = null;
-        
+
         dialogueId = 0;
         stmtLabel = "";
         APIType = 0;
@@ -156,29 +160,29 @@ public class ServerApiGetCatalogs {
         fkCatalogNm = "";
         fkSchemaNm = "";
         fkTableNm = "";
-        
+
         errorList = null;
         proxySyntax = "";
-        
+
         trafConn = null;
         serverException = null;
     }
-    ClientData processApi(ClientData clientData) {  
+    ClientData processApi(ClientData clientData) {
         this.clientData = clientData;
         init();
-//        
+//
 // ==============process input ByteBuffer===========================
-// 
+//
         ByteBuffer bbHeader = clientData.bbHeader;
         ByteBuffer bbBody = clientData.bbBody;
         Header hdr = clientData.hdr;
 
         bbHeader.flip();
         bbBody.flip();
-        
+
         try {
             hdr.extractFromByteArray(bbHeader);
-            
+
             dialogueId =  bbBody.getInt();
             stmtLabel = ByteBufferUtils.extractString(bbBody);
             APIType =  bbBody.getShort();
@@ -197,7 +201,7 @@ public class ServerApiGetCatalogs {
             fkCatalogNm = ByteBufferUtils.extractString(bbBody);
             fkSchemaNm = ByteBufferUtils.extractString(bbBody);
             fkTableNm = ByteBufferUtils.extractString(bbBody);
-            
+
             if(LOG.isDebugEnabled()){
                 LOG.debug(serverWorkerName + ". dialogueId :" + dialogueId);
                 LOG.debug(serverWorkerName + ". stmtLabel :" + stmtLabel);
@@ -227,29 +231,37 @@ public class ServerApiGetCatalogs {
 //=====================Process ServerApiGetCatalogs===========================
             try {
                 trafConn = clientData.getTrafConnection();
-                trafStmt = trafConn.createTrafStatement(stmtLabel, true);
-                trafStmt.setResultSet(null);
-    
+                trafStmt = trafConn.createTrafStatement(stmtLabel, ServerConstants.TYPE_CATOLOG, 0);
+//              trafStmt.setResultSet(null);
+
                 dbmd = trafConn.getConnection().getMetaData();
                 switch(APIType){
+                    case ServerConstants.SQL_API_SQLTABLES:                 //odbc
+                        if (tableNm.equals("") == false){
+                           if (tableTypeList == null || tableTypeList.equals("")){
+                               if(LOG.isDebugEnabled())
+                                   LOG.debug(serverWorkerName + ". getTables (catalogNm :" + catalogNm + ", schemaNm :" + schemaNm + ", tableNm :" + tableNm + ", tableTypeList :null)");
+                               rs = dbmd.getTables(catalogNm, schemaNm, tableNm, null);
+                           }
+                           else {
+                               if(LOG.isDebugEnabled())
+                                   LOG.debug(serverWorkerName + ". getTables (catalogNm :" + catalogNm + ", schemaNm :" + schemaNm + ", tableNm :" + tableNm + ", tableTypeList :" + tableTypeList + ")");
+                               String[] tpList = tableTypeList.split(",");
+                               rs = dbmd.getTables(catalogNm, schemaNm, tableNm, tpList);
+                           }
+                        }
+                        else if (catalogNm.equals("%") == true){
+                            if(LOG.isDebugEnabled())
+                                LOG.debug(serverWorkerName + ". getCatalogs()");
+                            rs = dbmd.getCatalogs();
+                        }
+                        else if (schemaNm.equals("%") == true){
+                            if(LOG.isDebugEnabled())
+                                LOG.debug(serverWorkerName + ". getSchemas()");
+                            rs = dbmd.getSchemas();
+                        }
+                        break;
                     case ServerConstants.SQL_API_SQLTABLES_JDBC:
-/*
- getCatalogs()
-                "%", // catalog
-                "", // schema
-                "", // table name
-                "", // tableTypeList
-getSchemas()
-                "", // catalog
-                "%", // schema
-                "", // table name
-                "", // tableTypeList
-getTables
-                catalogNm, // catalog
-                schemaNm, // schema
-                tableNm, // table name
-                tableTypeList, // tableTypeList
- */
                         if (tableNm.equals("") == false){
                            if (tableTypeList == null || tableTypeList.equals("")){
                                if(LOG.isDebugEnabled())
@@ -274,6 +286,11 @@ getTables
                             rs = dbmd.getSchemas();
                         }
                         break;
+                    case ServerConstants.SQL_API_SQLCOLUMNS:        //odbc
+                        if(LOG.isDebugEnabled())
+                            LOG.debug(serverWorkerName + ". getColumns (catalogNm :" + catalogNm + ", schemaNm :" + schemaNm + ", tableNm:" + tableNm + ", columnNm :" + columnNm + ")");
+                        rs = dbmd.getColumns(catalogNm, schemaNm, tableNm, columnNm);
+                        break;
                     case ServerConstants.SQL_API_SQLCOLUMNS_JDBC:
                         if(LOG.isDebugEnabled())
                             LOG.debug(serverWorkerName + ". getColumns (catalogNm :" + catalogNm + ", schemaNm :" + schemaNm + ", tableNm:" + tableNm + ", columnNm :" + columnNm + ")");
@@ -339,26 +356,26 @@ getTables
                         rs = dbmd.getIndexInfo(catalogNm, schemaNm, tableNm, (uniqueness == 1)? true : false, true);
                        break;
                     default:
-                        throw new SQLException(serverWorkerName + ". Unknown APIType sent by the Client : [" + APIType + "]");
+                        throw new SQLException(serverWorkerName + ". Unknown APIType sent by the Client : [" + APIType + "]", "HY024");
                 }
-                trafStmt.setResultSet(rs);
+//              trafStmt.setResultSet(rs);
                 rsmd = rs.getMetaData();
-                resultSetColumns = rsmd.getColumnCount();
-                
+                outCount = rsmd.getColumnCount();
+
             } catch (SQLException se){
                 LOG.error(serverWorkerName + ". GetCatalogs.SQLException " + se);
-                errorList = new SQLWarningOrErrorList(se); 
-                serverException.setServerException (odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_, 0, se);                
+                errorList = new SQLWarningOrErrorList(se);
+                serverException.setServerException (odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_, 0, se);
             } catch (Exception ex){
                 LOG.error(serverWorkerName + ". GetCatalogs.Exception " + ex);
                 throw ex;
             }
-            if (resultSetColumns > 0){
+            if (outCount > 0){
                 strsmd = (SQLMXResultSetMetaData)rsmd;
-                resultSetDescList = new Descriptor2List(resultSetColumns, true);
-                
-                numResultSets = 1;
-                for (int column = 1; column <= resultSetColumns; column++){
+                outDescList = new Descriptor2List(outCount, true);
+
+                resultSetCount = 1;
+                for (int column = 1; column <= outCount; column++){
                     sqlCharset_ = strsmd.getSqlCharset(column);
                     odbcCharset_ = strsmd.getOdbcCharset(column);
                     sqlDataType_ = strsmd.getSqlDataType(column);
@@ -381,24 +398,24 @@ getTables
                     paramMode_ = strsmd.getMode(column);
                     paramIndex_ = strsmd.getIndex(column);
                     paramPos_ = strsmd.getPos(column);
-                    
+
                     odbcPrecision_ = strsmd.getOdbcPrecision(column);
                     maxLen_ = strsmd.getMaxLen(column);
-                    
+
                     displaySize_ = strsmd.getDisplaySize(column);
                     label_ = strsmd.getLabel(column);
 
-                    Descriptor2 outDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
+                    Descriptor2 columnDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
                         sqlOctetLength_,isNullable_,name_,scale_,precision_,isSigned_,
                         isCurrency_,isCaseSensitive_,catalogName_,schemaName_,tableName_,
                         fsDataType_,intLeadPrec_,paramMode_,paramIndex_,paramPos_,odbcPrecision_,
                         maxLen_,displaySize_,label_, true);
-                    resultSetDescList.addDescriptor(column,outDesc);
+                    outDescList.addDescriptor(column,columnDesc);
                 }
                 if(LOG.isDebugEnabled()){
-                    for (int column = 1; column <= resultSetColumns; column++){
-                        Descriptor2 dsc = resultSetDescList.getDescriptors2()[column-1];
-                        LOG.debug(serverWorkerName + ". [" + column + "] Output descriptor -------------" );
+                    for (int column = 1; column <= outCount; column++){
+                        Descriptor2 dsc = outDescList.getDescriptors2()[column-1];
+                        LOG.debug(serverWorkerName + ". [" + column + "] Column descriptor -------------" );
                         LOG.debug(serverWorkerName + ". oldFormat " + column + " :" + dsc.getOldFormat());
                         LOG.debug(serverWorkerName + ". noNullValue " + column + " :" + dsc.getNoNullValue());
                         LOG.debug(serverWorkerName + ". nullValue " + column + " :" + dsc.getNullValue());
@@ -420,18 +437,21 @@ getTables
                         LOG.debug(serverWorkerName + ". headingName " + column + " :" + dsc.getHeadingName());
                         LOG.debug(serverWorkerName + ". intLeadPrec " + column + " :" + dsc.getParamMode());
                         LOG.debug(serverWorkerName + ". paramMode " + column + " :" + dsc.getColHeadingNm());
-                        LOG.debug(serverWorkerName + ". memAlignOffset " + column + " :" + dsc.getMemAlignOffset());
-                        LOG.debug(serverWorkerName + ". allocSize " + column + " :" + dsc.getAllocSize());
-                        LOG.debug(serverWorkerName + ". varLayout " + column + " :" + dsc.getVarLayout());
-                        LOG.debug(serverWorkerName + ". Output descriptor End-------------");
-                    }
-                    trafStmt.setOutNumberParams(resultSetColumns);
-                    if (resultSetColumns > 0){
-                        trafStmt.setOutParamLength(resultSetDescList.getParamLength());
-                        trafStmt.setOutDescList(resultSetDescList);
+                        LOG.debug(serverWorkerName + ". varLength " + column + " :" + dsc.getVarLength());
+                        LOG.debug(serverWorkerName + ". Column descriptor End-------------");
                     }
                 }
             }
+            if (outCount > 0){
+                trafStmt.addTResultSet(new TrafResultSet(rs, 0, stmtLabel, 0, outDescList,""));
+            }
+/*
+            trafStmt.setoutCount(outCount);
+            if (outCount > 0){
+                trafStmt.setColumnLength(outDescList.getVarLength());
+                trafStmt.setoutDescList(outDescList);
+            }
+*/
 //
 //===================calculate length of output ByteBuffer========================
 //
@@ -439,7 +459,7 @@ getTables
             bbBody.clear();
 //
 // check if ByteBuffer is big enough for output
-//      
+//
 //===================== build output ==============================================
 //
 /*          odbc_SQLSvc_GetSQLCatalogs_exc_ m_p1;
@@ -449,11 +469,11 @@ getTables
             String proxySyntax = "";
 */
 // check if ByteBuffer is big enough for output
-//  
+//
             int dataLength = serverException.lengthOfData();
             dataLength += ByteBufferUtils.lengthOfString(stmtLabel); //stmtLabel
-            if (resultSetDescList != null)
-                dataLength += resultSetDescList.lengthOfData();
+            if (outDescList != null)
+                dataLength += outDescList.lengthOfData();
             else
                 dataLength += ServerConstants.INT_FIELD_SIZE;
             if (errorList != null)
@@ -461,7 +481,7 @@ getTables
             else
                 dataLength += ServerConstants.INT_FIELD_SIZE;
             dataLength += ByteBufferUtils.lengthOfString(proxySyntax); //proxySyntax
-            
+
             int availableBuffer = bbBody.capacity() - bbBody.position();
             if(LOG.isDebugEnabled())
                 LOG.debug(serverWorkerName + ". dataLength :" + dataLength + " availableBuffer :" + availableBuffer);
@@ -471,19 +491,18 @@ getTables
 //===================== build output ==============================================
             serverException.insertIntoByteBuffer(bbBody);
             ByteBufferUtils.insertString(stmtLabel, bbBody);
-            if (resultSetDescList != null)
-                resultSetDescList.insertIntoByteBuffer(bbBody);
+            if (outDescList != null)
+                outDescList.insertIntoByteBuffer(bbBody);
             else
                 bbBody.putInt(0);
             if (errorList != null)
                 errorList.insertIntoByteBuffer(bbBody);
             else
                 bbBody.putInt(0);
-            
-            ByteBufferUtils.insertString(proxySyntax, bbBody);
 
+            ByteBufferUtils.insertString(proxySyntax, bbBody);
             bbBody.flip();
-//=========================Update header================================ 
+//=========================Update header================================
             hdr.setTotalLength(bbBody.limit());
             hdr.insertIntoByteBuffer(bbHeader);
             bbHeader.flip();
@@ -503,3 +522,68 @@ getTables
         return clientData;
     }
 }
+/*
+//
+// length of odbc_SQLSvc_GetSQLCatalogs_exc_ *exception_
+//
+    wlength += sizeof(exception_->exception_nr);
+    wlength += sizeof(exception_->exception_detail);
+
+    switch(exception_->exception_nr)
+    {
+        case odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_:
+           wlength += sizeof(exceptionLength);
+           if (exception_->u.ParamError.ParamDesc != NULL)
+           {
+              exceptionLength = strlen(exception_->u.ParamError.ParamDesc) + 1;
+              wlength += exceptionLength;
+           }
+           break;
+
+        case odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_:
+            ERROR_DESC_LIST_length( (ERROR_DESC_LIST_def *)&exception_->u.SQLError.errorList, wlength);
+            break;
+
+        case odbc_SQLSvc_GetSQLCatalogs_InvalidConnection_exn_:
+        case odbc_SQLSvc_GetSQLCatalogs_SQLInvalidHandle_exn_:
+            break;
+        default:
+            break;
+    }
+
+//
+// length of IDL_char *catStmtLabel
+//
+    wlength += sizeof(catStmtLabelLength);
+    if (catStmtLabel != NULL)
+    {
+        catStmtLabelLength = strlen(catStmtLabel)+1;
+        wlength += catStmtLabelLength;
+    }
+
+//
+// length of SQLItemDescList_def *outputDesc
+//
+    SQLITEMDESC_LIST_length( outputDesc, wlength);
+
+//
+// length of ERROR_DESC_LIST_def *sqlWarning
+//
+//
+    ERROR_DESC_LIST_LENGTH2(sqlWarning)
+
+//
+//
+//
+
+  wlength += sizeof (proxySyntaxStringLen);
+
+  if((pSrvrStmt != NULL) && (pSrvrStmt->SpjProxySyntaxString != NULL))
+    proxySyntaxStringLen = strlen(pSrvrStmt->SpjProxySyntaxString);
+  else
+    proxySyntaxStringLen = 0;
+
+  if(proxySyntaxStringLen > 0)
+    wlength += proxySyntaxStringLen + 1; // null terminated string
+
+ */

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecDirect.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecDirect.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecDirect.java
index 4a62eff..d2c8448 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecDirect.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecDirect.java
@@ -51,7 +51,7 @@ public class ServerApiSqlExecDirect {
     private ClientData clientData;
     //
     private int dialogueId;
-    private int sqlAsyncEnable;
+    private int holdableCursor;
     private int queryTimeout;
     private int inpRowCnt;
     private int maxRowsetSize;
@@ -62,16 +62,15 @@ public class ServerApiSqlExecDirect {
     private String cursorName;
     private String stmtLabel;
     private String stmtExplainLabel;
-    private SQLDataValue inpDataValue;
-    private SQLValueList inpValueList;
     private byte[] txId;
-    
-    private int holdableCursor;
-//=======================================================================    
+
+//=======================================================================
+    private boolean isResultSet;
+    private boolean isSpj;
     private Statement stmt;
     private TrafConnection trafConn;
     private TrafStatement trafStmt;
-//-------------------output-------------------------------------    
+//-------------------output-------------------------------------
     private int returnCode;
     private SQLWarningOrErrorList errorList;
     private long rowsAffected;
@@ -80,9 +79,9 @@ public class ServerApiSqlExecDirect {
     private byte[] outValues;
 
 //----------- tmp for result set --------------------
-    private int numResultSets;
-    private int resultSetColumns;
-    private Descriptor2List resultSetDescList;
+    private int resultSetCount;
+    private int outCount;
+    private Descriptor2List outDescList;
     private ResultSet rs;
     private ResultSetMetaData rsmd;
     private TResultSetMetaData trsmd;
@@ -119,8 +118,8 @@ public class ServerApiSqlExecDirect {
 
     private int     displaySize_;
     private String  label_;
-    
-    ServerApiSqlExecDirect(int instance, int serverThread) {  
+
+    ServerApiSqlExecDirect(int instance, int serverThread) {
         this.instance = instance;
         this.serverThread = serverThread;
         serverWorkerName = ServerConstants.SERVER_WORKER_NAME + "_" + instance + "_" + serverThread;
@@ -130,7 +129,6 @@ public class ServerApiSqlExecDirect {
     }
     void reset(){
         dialogueId = 0;
-        sqlAsyncEnable = 0;
         queryTimeout = 0;
         inpRowCnt = 0;
         maxRowsetSize = 0;
@@ -154,9 +152,9 @@ public class ServerApiSqlExecDirect {
         sqlQueryType = 0;
         estimatedCost = 0;
         outValues = null;
-        numResultSets = 0;
-        resultSetColumns = 0;
-        resultSetDescList = null;
+        resultSetCount = 0;
+        outCount = 0;
+        outDescList = null;
         rs = null;
         rsmd = null;
         trsmd = null;
@@ -165,23 +163,23 @@ public class ServerApiSqlExecDirect {
         singleSyntax = "";
         proxySyntax = null;
     }
-    ClientData processApi(ClientData clientData) {  
+    ClientData processApi(ClientData clientData) {
         init();
         this.clientData = clientData;
-//        
+//
 // ==============process input ByteBuffer===========================
-// 
+//
         ByteBuffer bbHeader = clientData.bbHeader;
         ByteBuffer bbBody = clientData.bbBody;
         Header hdr = clientData.hdr;
 
         bbHeader.flip();
         bbBody.flip();
-        
+
         try {
 
             hdr.extractFromByteArray(bbHeader);
-            
+
             dialogueId =  bbBody.getInt();
             holdableCursor =  bbBody.getInt();
             queryTimeout =  bbBody.getInt();
@@ -217,31 +215,15 @@ public class ServerApiSqlExecDirect {
                 throw new SQLException(serverWorkerName + ". Wrong dialogueId sent by the Client [sent/expected] : [" + dialogueId + "/" + clientData.getDialogueId() + "]");
             }
 //=============================================================================
-            boolean isResultSet = false;
-            sqlQueryType = sqlStmtType;
-            
-            switch (sqlStmtType){
-                case ServerConstants.TYPE_SELECT:
-                case ServerConstants.TYPE_EXPLAIN:
-                    isResultSet = true;
-                    break;
-                case ServerConstants.TYPE_UPDATE:
-                case ServerConstants.TYPE_DELETE:
-                case ServerConstants.TYPE_INSERT:
-                case ServerConstants.TYPE_INSERT_PARAM:
-                case ServerConstants.TYPE_CREATE:
-                case ServerConstants.TYPE_GRANT:
-                case ServerConstants.TYPE_DROP:
-                case ServerConstants.TYPE_CALL:
-                case ServerConstants.TYPE_CONTROL:
-                default:
-            }
+            sqlQueryType = SqlUtils.getSqlStmtType(sqlStmtType);
+
             try {
                 trafConn = clientData.getTrafConnection();
-                trafStmt = trafConn.createTrafStatement(stmtLabel, isResultSet);
-                trafStmt.setResultSet(null);
+                trafStmt = trafConn.createTrafStatement(stmtLabel, sqlStmtType, stmtHandle);
+                isResultSet = trafStmt.getIsResultSet();
+                isSpj = trafStmt.getIsSpj();
                 stmt = (Statement)trafStmt.getStatement();
-//            
+//
 //=====================Process ServerApiSqlExecute===========================
 //
                 boolean status = stmt.execute(sqlString);
@@ -250,10 +232,9 @@ public class ServerApiSqlExecDirect {
                 if(status){
                     rs = stmt.getResultSet();
                     rsmd = rs.getMetaData();
-                    trafStmt.setResultSet(rs);
                     if(LOG.isDebugEnabled())
                         LOG.debug(serverWorkerName + ". T2 Execute.getResultSet()");
-                    resultSetColumns = rsmd.getColumnCount();
+                    outCount = rsmd.getColumnCount();
                 } else {
                     rowsAffected = stmt.getUpdateCount();
                     if(LOG.isDebugEnabled())
@@ -261,25 +242,18 @@ public class ServerApiSqlExecDirect {
                 }
             } catch (SQLException se){
                 LOG.error(serverWorkerName + ". ExecDirect.SQLException " + se);
-                errorList = new SQLWarningOrErrorList(se); 
+                errorList = new SQLWarningOrErrorList(se);
                 returnCode = errorList.getReturnCode();
             } catch (Exception ex){
                 LOG.error(serverWorkerName + ". ExecDirect.Exception " + ex);
                 throw ex;
             }
             if (returnCode == ServerConstants.SQL_SUCCESS || returnCode == ServerConstants.SQL_SUCCESS_WITH_INFO) {
-                if (resultSetColumns > 0){
+                if (outCount > 0){
                     strsmd = (SQLMXResultSetMetaData)rsmd;
-                    resultSetDescList = new Descriptor2List(resultSetColumns,false);
-                    
-                    numResultSets = 1;
-                    stmtLabels = new String[numResultSets];
-                    proxySyntax = new String[numResultSets];
-                    singleSyntax = "";
-                    stmtLabels[0] = stmtLabel;
-                    proxySyntax[0] = "";
-                    
-                    for (int column = 1; column <= resultSetColumns; column++){
+                    outDescList = new Descriptor2List(outCount,false);
+
+                    for (int column = 1; column <= outCount; column++){
                         sqlCharset_ = strsmd.getSqlCharset(column);
                         odbcCharset_ = strsmd.getOdbcCharset(column);
                         sqlDataType_ = strsmd.getSqlDataType(column);
@@ -302,24 +276,24 @@ public class ServerApiSqlExecDirect {
                         paramMode_ = strsmd.getMode(column);
                         paramIndex_ = strsmd.getIndex(column);
                         paramPos_ = strsmd.getPos(column);
-                        
+
                         odbcPrecision_ = strsmd.getOdbcPrecision(column);
                         maxLen_ = strsmd.getMaxLen(column);
-                        
+
                         displaySize_ = strsmd.getDisplaySize(column);
                         label_ = strsmd.getLabel(column);
-    
-                        Descriptor2 outDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
+
+                        Descriptor2 columnDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
                             sqlOctetLength_,isNullable_,name_,scale_,precision_,isSigned_,
                             isCurrency_,isCaseSensitive_,catalogName_,schemaName_,tableName_,
                             fsDataType_,intLeadPrec_,paramMode_,paramIndex_,paramPos_,odbcPrecision_,
                             maxLen_,displaySize_,label_, false);
-                        resultSetDescList.addDescriptor(column,outDesc);
+                        outDescList.addDescriptor(column, columnDesc);
                     }
                     if(LOG.isDebugEnabled()){
-                        for (int column = 1; column <= resultSetColumns; column++){
-                            Descriptor2 dsc = resultSetDescList.getDescriptors2()[column-1];
-                            LOG.debug(serverWorkerName + ". [" + column + "] Output descriptor -------------" );
+                        for (int column = 1; column <= outCount; column++){
+                            Descriptor2 dsc = outDescList.getDescriptors2()[column-1];
+                            LOG.debug(serverWorkerName + ". [" + column + "] Column descriptor -------------" );
                             LOG.debug(serverWorkerName + ". oldFormat " + column + " :" + dsc.getOldFormat());
                             LOG.debug(serverWorkerName + ". noNullValue " + column + " :" + dsc.getNoNullValue());
                             LOG.debug(serverWorkerName + ". nullValue " + column + " :" + dsc.getNullValue());
@@ -341,18 +315,13 @@ public class ServerApiSqlExecDirect {
                             LOG.debug(serverWorkerName + ". headingName " + column + " :" + dsc.getHeadingName());
                             LOG.debug(serverWorkerName + ". intLeadPrec " + column + " :" + dsc.getParamMode());
                             LOG.debug(serverWorkerName + ". paramMode " + column + " :" + dsc.getColHeadingNm());
-                            LOG.debug(serverWorkerName + ". memAlignOffset " + column + " :" + dsc.getMemAlignOffset());
-                            LOG.debug(serverWorkerName + ". allocSize " + column + " :" + dsc.getAllocSize());
-                            LOG.debug(serverWorkerName + ". varLayout " + column + " :" + dsc.getVarLayout());
-                            LOG.debug(serverWorkerName + ". Output descriptor End-------------");
+                            LOG.debug(serverWorkerName + ". varLength " + column + " :" + dsc.getVarLength());
+                            LOG.debug(serverWorkerName + ". Column descriptor End-------------");
                         }
                     }
-                    trafStmt.setOutNumberParams(resultSetColumns);
-                    if (resultSetColumns > 0){
-                        trafStmt.setOutParamLength(resultSetDescList.getParamLength());
-                        trafStmt.setOutDescList(resultSetDescList);
-                    }
                 }
+                if (outCount > 0)
+                    trafStmt.addTResultSet(new TrafResultSet(rs, 0, stmtLabel, 0, outDescList,""));
             }
 //
 //===================calculate length of output ByteBuffer========================
@@ -361,36 +330,35 @@ public class ServerApiSqlExecDirect {
             bbBody.clear();
 //
 // check if ByteBuffer is big enough for output
-//  
+//
+            TrafResultSet trs = null;
+
             int dataLength = ServerConstants.INT_FIELD_SIZE;                 //returnCode
             if (errorList != null)
                 dataLength += errorList.lengthOfData();
             else
                 dataLength += ServerConstants.INT_FIELD_SIZE;             //totalErrorLength = 0
 
-            dataLength += ServerConstants.INT_FIELD_SIZE;             //outDescLength = 0
+            if (outDescList != null)
+                dataLength += outDescList.lengthOfData();
+            else
+                dataLength += ServerConstants.INT_FIELD_SIZE;             //outDescLength = 0
 
             dataLength += ServerConstants.INT_FIELD_SIZE;                 //rowsAffected
             dataLength += ServerConstants.INT_FIELD_SIZE;                 //queryType
             dataLength += ServerConstants.INT_FIELD_SIZE;                 //estimatedCost
-            dataLength += ByteBufferUtils.lengthOfByteArray(outValues); //outValues
+            dataLength += ByteBufferUtils.lengthOfByteArray(outValues);   //outValues
             dataLength += ServerConstants.INT_FIELD_SIZE;                 //numResultSets
-            if (numResultSets > 0) {
-                for (int i = 0; i < numResultSets; i++) {
-                    dataLength += ServerConstants.INT_FIELD_SIZE;         //stmt_handle
-                    dataLength += ByteBufferUtils.lengthOfString(stmtLabels[i]); //stmtLabels
-                    dataLength += ServerConstants.INT_FIELD_SIZE;         //stmt_label_charset
-                    
-                    if (resultSetDescList != null)
-                        dataLength += resultSetDescList.lengthOfData();
-                    else
-                        dataLength += ServerConstants.INT_FIELD_SIZE;
-                
-                    dataLength += ByteBufferUtils.lengthOfString(proxySyntax[i]); //proxySyntax[i]
+            if (resultSetCount > 0) {
+                trafStmt.setFirstTResultSet();
+                while (true) {
+                    trs = trafStmt.getTrafResultSet();
+                    dataLength += trs.lengthOfData();
+                    if(false == trafStmt.getNextTResultSet()) break;
                 }
             }
             dataLength += ByteBufferUtils.lengthOfString(singleSyntax);
-            
+
             int availableBuffer = bbBody.capacity() - bbBody.position();
             if(LOG.isDebugEnabled())
                 LOG.debug(serverWorkerName + ". dataLength :" + dataLength + " availableBuffer :" + availableBuffer);
@@ -405,33 +373,31 @@ public class ServerApiSqlExecDirect {
                 errorList.insertIntoByteBuffer(bbBody);
             else
                 bbBody.putInt(0);
-            
-            bbBody.putInt(0);             //outDescLength = 0
-            
+
+            if (outDescList != null){
+                outDescList.insertIntoByteBuffer(bbBody);
+            } else
+                bbBody.putInt(0);
+
             ByteBufferUtils.insertUInt(rowsAffected, bbBody);
             bbBody.putInt(sqlQueryType);
             bbBody.putInt(estimatedCost);
             ByteBufferUtils.insertByteArray(outValues, bbBody);     //outValues
-            bbBody.putInt(numResultSets);
-
-            if (numResultSets > 0) {
-                for (int i = 0; i < numResultSets; i++) {
-                    bbBody.putInt(0); // int stmt_handle - ignored
-                    ByteBufferUtils.insertString(stmtLabels[i], bbBody);
-                    bbBody.putInt(0); // long stmt_label_charset - ignored
-                    
-                    if (resultSetDescList != null)
-                         resultSetDescList.insertIntoByteBuffer(bbBody);
-                    else
-                        bbBody.putInt(0);
-                    
-                    ByteBufferUtils.insertString(proxySyntax[i], bbBody);
+            bbBody.putInt(resultSetCount);
+
+            if (resultSetCount > 0) {
+                trafStmt.setFirstTResultSet();
+                while (true) {
+                    trs = trafStmt.getTrafResultSet();
+                    trs.insertIntoByteBuffer(bbBody);
+                    if(false == trafStmt.getNextTResultSet()) break;
                 }
+                trafStmt.setFirstTResultSet();
             }
             ByteBufferUtils.insertString(singleSyntax, bbBody);
 
             bbBody.flip();
-//=========================Update header================================ 
+//=========================Update header================================
             hdr.setTotalLength(bbBody.limit());
             hdr.insertIntoByteBuffer(bbHeader);
             bbHeader.flip();


[3/6] incubator-trafodion git commit: Delivering multithreaded code to support resultsets.

Posted by su...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecute.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecute.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecute.java
index 2044bb1..ed56cc3 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecute.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlExecute.java
@@ -34,6 +34,7 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
 import java.text.ParseException;
+import java.math.*;
 
 import org.trafodion.jdbc.t2.*;
 
@@ -65,7 +66,7 @@ public class ServerApiSqlExecute {
     private ClientData clientData;
 //
     private int dialogueId;
-    private int sqlAsyncEnable;
+    private int holdableCursor;
     private int queryTimeout;
     private int inpRowCnt;
     private int maxRowsetSize;
@@ -76,51 +77,52 @@ public class ServerApiSqlExecute {
     private String cursorName;
     private String stmtLabel;
     private String stmtExplainLabel;
-    private SQLDataValue inpDataValue;
-    private SQLValueList inpValueList;
     private byte[] txId;
-    
-    private int holdableCursor;
-//======================================================================= 
+
+//=======================================================================
+    private boolean isResultSet;
+    private boolean isSpj;
+    private Object stmt;
     private PreparedStatement pstmt;
+    private CallableStatement cstmt;
     private TrafConnection trafConn;
     private TrafStatement trafStmt;
-//------------------input-------------------------------------    
-    private int inpNumberParams;
-    private long inpParamLength;
-    private int inpValuesLength;
-    private Descriptor2List inpDescList;
-    private int iret;
-
-    private int outNumberParams;
+//------------------Parameters----------------------------------
+    private int regParamCount;
+    private int paramCount;
+    private long paramLength;
+    private Descriptor2List paramDescList;
+    private Descriptor2 paramDesc;
+    private int paramValuesLength;
+//------------------output Values-------------------------------
+    private int outValuesLength;
+    private byte[] outValues;
+//--------------------------------------------------------------
     private Descriptor2List outDescList;
     private ResultSet rs;
     private ResultSetMetaData rsMD;
-//-------------------output-------------------------------------    
+//-------------------output-------------------------------------
     private int returnCode;
     private SQLWarningOrErrorList errorList;
     private long rowsAffected;
     private int sqlQueryType;
     private int estimatedCost;
-    private byte[] outValues;
-    
-    private int numResultSets;
-    private Descriptor2List resultSetDescList;
+
+    private int resultSetCount;
     private String[] stmtLabels;
     private String[] proxySyntax;
     private String singleSyntax;
-//---------------------------------------------------------------
-    ServerApiSqlExecute(int instance, int serverThread) {  
+//-------------------------------------------------------------
+    ServerApiSqlExecute(int instance, int serverThread) {
         this.instance = instance;
         this.serverThread = serverThread;
         serverWorkerName = ServerConstants.SERVER_WORKER_NAME + "_" + instance + "_" + serverThread;
     }
-    void init(){
+    void init() {
         reset();
     }
-    void reset(){
+    void reset() {
         dialogueId = 0;
-        sqlAsyncEnable = 0;
         queryTimeout = 0;
         inpRowCnt = 0;
         maxRowsetSize = 0;
@@ -131,69 +133,71 @@ public class ServerApiSqlExecute {
         cursorName = null;
         stmtLabel = null;
         stmtExplainLabel = null;
-        inpDataValue = null;
-        inpValuesLength = 0;
-        txId = null;     // JDBC is the only one that will use this to join a transaction
+        txId = null; // JDBC is the only one that will use this to join a transaction
 
-        holdableCursor = 0; //default
+        holdableCursor = 0;//default
 //==================================================================
+        isResultSet = false;
+        isSpj = false;
+        stmt = null;
+        pstmt = null;
+        cstmt = null;
         trafConn = null;
         trafStmt = null;
-//-----------------------------input--------------------------------------
-        inpNumberParams = 0;
-        inpParamLength = 0;
-        inpValuesLength = 0;
-        inpDescList = null;
-        iret = 0;
-//------------------------------output------------------------------------        
+//-----------------------------params--------------------------------------
+        regParamCount = 0;
+        paramCount = 0;
+        paramLength = 0;
+        paramDescList = null;
+        paramDesc = null;
+        paramValuesLength = 0;
+//------------------------------output-------------------------------------
         returnCode = 0;
         errorList = null;
         rowsAffected = 0;
         sqlQueryType = 0;
         estimatedCost = 0;
-        outNumberParams = 0;
+
+        outValuesLength = 0;
+        outValues = null;
+        resultSetCount = 0;
         outDescList = null;
         rs = null;
         rsMD = null;
-
-        outValues = null;
-        numResultSets = 0;
-        resultSetDescList = null;
         stmtLabels = null;
         singleSyntax = "";
         proxySyntax = null;
     }
-    ClientData processApi(ClientData clientData) {  
+    ClientData processApi(ClientData clientData) {
         init();
         this.clientData = clientData;
-//        
+//
 // ==============process input ByteBuffer===========================
-// 
+//
         ByteBuffer bbHeader = clientData.bbHeader;
         ByteBuffer bbBody = clientData.bbBody;
         Header hdr = clientData.hdr;
 
         bbHeader.flip();
         bbBody.flip();
-        
+
         try {
             hdr.extractFromByteArray(bbHeader);
-            
-            dialogueId =  bbBody.getInt();
-            holdableCursor =  bbBody.getInt();
-            queryTimeout =  bbBody.getInt();
-            inpRowCnt =  bbBody.getInt();
-            maxRowsetSize =  bbBody.getInt();
-            sqlStmtType =  bbBody.getInt();
-            stmtHandle =  bbBody.getInt();
-            stmtType =  bbBody.getInt();
+
+            dialogueId = bbBody.getInt();
+            holdableCursor = bbBody.getInt();
+            queryTimeout = bbBody.getInt();
+            inpRowCnt = bbBody.getInt();
+            maxRowsetSize = bbBody.getInt();
+            sqlStmtType = bbBody.getInt();
+            stmtHandle = bbBody.getInt();
+            stmtType = bbBody.getInt();
             sqlString = ByteBufferUtils.extractStringWithCharset(bbBody);
             cursorName = ByteBufferUtils.extractStringWithCharset(bbBody);
             stmtLabel = ByteBufferUtils.extractStringWithCharset(bbBody);
             stmtExplainLabel = ByteBufferUtils.extractString(bbBody);
 //            txId = ByteBufferUtils.extractByteArray(bbBody);
             if(LOG.isDebugEnabled()) {
-//                ByteBufferUtils.toHexString("inputValueList", bbBody);
                 LOG.debug(serverWorkerName + ". dialogueId :" + dialogueId);
                 LOG.debug(serverWorkerName + ". holdableCursor :" + holdableCursor);
                 LOG.debug(serverWorkerName + ". queryTimeout :" + queryTimeout);
@@ -216,168 +220,218 @@ public class ServerApiSqlExecute {
             }
 //=============================================================================
             trafConn = clientData.getTrafConnection();
-            trafStmt = trafConn.getTrafStatement(stmtLabel);
-            trafStmt.setResultSet(null);
-            pstmt = (PreparedStatement)trafStmt.getStatement();
-            
-            boolean isResultSet = trafStmt.getIsResultSet();
-//            
+            trafStmt = trafConn.getTrafStatement(stmtLabel, stmtHandle);
+
+            isResultSet = trafStmt.getIsResultSet();
+            isSpj = trafStmt.getIsSpj();
+            stmt = trafStmt.getStatement();
+            if (isSpj == true) cstmt = (CallableStatement)stmt; else pstmt = (PreparedStatement)stmt;
+//
 //=====================Process ServerApiSqlExecute===========================
 //
             try {
                 int addedBatches = 0;
-                inpNumberParams = trafStmt.getInpNumberParams();
-                if (inpNumberParams > 0){
+                paramCount = trafStmt.getParamCount();
+                if (paramCount > 0) {
+                    long startOffset;
+                    int rowCount;
+                    int paramRowCount;
+                    int paramMode;
+
                     if(LOG.isDebugEnabled())
-                        ByteBufferUtils.toHexString("inputValueList", bbBody, 10);
-                    inpDescList = trafStmt.getInpDescList();
-                    inpParamLength = trafStmt.getInpParamLength();
-                    inpValuesLength = bbBody.getInt();
-                    if(LOG.isDebugEnabled()){
-                        LOG.debug("inpValuesLength :" + inpValuesLength);
-                        LOG.debug("inpParamLength :" + inpParamLength);
+                    ByteBufferUtils.toHexString("inValues", bbBody, 10);
+                    paramDescList = trafStmt.getParamDescList();
+                    paramLength = trafStmt.getParamLength();
+                    paramValuesLength = bbBody.getInt();
+                    if(LOG.isDebugEnabled()) {
+                        LOG.debug("paramValuesLength :" + paramValuesLength);
+                        LOG.debug("paramLength :" + paramLength);
                     }
-                    if (inpValuesLength > 0){
-                        long startOffset = bbBody.position();
-                        int paramRowCount = inpRowCnt;
-                        int paramCount = inpNumberParams;
-                        for (int row = 0; row < inpRowCnt; row++) {
-                            for (int col = 0; col < inpNumberParams; col++) {
-                                bbBody = setInpParams(pstmt, inpDescList, paramRowCount, col, row, bbBody, startOffset);
+                    if (paramValuesLength > 0) {
+                        startOffset = bbBody.position();
+                        rowCount = inpRowCnt == 0 ? 1 : inpRowCnt;
+                        paramRowCount = rowCount;
+                        paramMode = 0;
+                        for (int row = 0; row < rowCount; row++) {
+                            for (int param = 1; param <= paramCount; param++) {
+                                paramDesc = paramDescList.getDescriptors2()[param - 1];
+                                paramMode = paramDesc.getParamMode();
+                                if ( paramMode == java.sql.ParameterMetaData.parameterModeOut) continue;
+                                bbBody = setData(paramDesc, paramRowCount, param, row, bbBody, startOffset);
                             }
-                            if (inpRowCnt > 1){
-                                pstmt.addBatch();
+                            if (rowCount > 1) {
+                                pstmt.addBatch(); // no SPJ
                                 addedBatches++;
                             }
+                            if(LOG.isDebugEnabled())
+                            LOG.debug("endof row :" + row + " addedBatches :" + addedBatches);
                         }
                     }
+                    if(LOG.isDebugEnabled())
+                        LOG.debug("addedBatches :" + addedBatches);
+
+                    for (int param = 1; param <= paramCount; param++) {
+                        paramDesc = paramDescList.getDescriptors2()[param - 1];
+                        paramMode = paramDesc.getParamMode();
+                        if ( paramMode == java.sql.ParameterMetaData.parameterModeIn) continue;
+                        if(LOG.isDebugEnabled())
+                        LOG.debug("registerOutParameter :" + param);
+                        regParamCount++;
+                        cstmt.registerOutParameter(param, java.sql.Types.VARCHAR);
+                    }
                 }
                 int txIdLen = bbBody.limit() - bbBody.position();
-                if (txIdLen > 0){
+                if (txIdLen > 0) {
                     txId = new byte[txIdLen];
                     bbBody.get(txId);
                 }
                 if(LOG.isDebugEnabled())
                     LOG.debug(serverWorkerName + ". txId :" + Arrays.toString(txId));
-               
-                if (addedBatches > 1){
-                    
+
+                if (addedBatches > 1) {
+
                     if(LOG.isDebugEnabled())
                         LOG.debug(serverWorkerName + ". T2 Execute.executeBatch()");
-                    
+
                     int[] numStatus = pstmt.executeBatch();
                     rowsAffected = numStatus.length;
-                    
+
                     if(LOG.isDebugEnabled())
                         LOG.debug(serverWorkerName + ". T2 Execute.executeBatch rowsAffected :" + rowsAffected);
                 }
-                else {
-                    if (isResultSet){
-                        rs = pstmt.executeQuery();
-                        trafStmt.setResultSet(rs);
-                        if(LOG.isDebugEnabled())
-                            LOG.debug(serverWorkerName + ". T2 Execute.executeQuery()");
+                else if (isResultSet) {
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". T2 Execute.executeQuery()");
+                    rs = pstmt.executeQuery();
+                    if (rs != null) {
+                        outDescList = trafStmt.getOutDescList();
+                        trafStmt.addTResultSet(new TrafResultSet(rs, 0, stmtLabel, 0, trafStmt.getOutDescList(),""));
                     }
-                    else {
-                        rowsAffected = pstmt.executeUpdate();
-                        if(LOG.isDebugEnabled())
-                             LOG.debug(serverWorkerName + ". T2 Execute.executeUpdate() rowsAffected :" + rowsAffected);
+                } else if (isSpj == true) {
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". SPJ T2 Execute.execute()");
+                    boolean rsAvailable = cstmt.execute();
+                    if (regParamCount > 0) { //out, inout parameters
+                        rowsAffected = 1;
+                        outValuesLength = (int)paramLength;
+                        outValues = new byte[outValuesLength];
+                        outValues = buildOutValues(paramDescList, outValues, paramCount, cstmt, bbBody.order());
+                    }
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". SPJ T2 Execute.rsAvailable :" + rsAvailable);
+                    if (rsAvailable == true) {
+                        setMultipleResultSets(cstmt);
                     }
+                } else {
+                    resultSetCount = 0;
+                    rowsAffected = pstmt.executeUpdate();
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". T2 Execute.executeUpdate() rowsAffected :" + rowsAffected);
                 }
-            } catch (BatchUpdateException bex){
+            } catch (BatchUpdateException bex) {
                 LOG.error(serverWorkerName + ". Execute.BatchUpdateException " + bex);
-                errorList = new SQLWarningOrErrorList(bex, bex.getUpdateCounts()); 
+                errorList = new SQLWarningOrErrorList(bex, bex.getUpdateCounts());
                 returnCode = errorList.getReturnCode();
-                
-            } catch (SQLException ex){
+
+            } catch (SQLException ex) {
                 LOG.error(serverWorkerName + ". Execute.SQLException " + ex);
-                errorList = new SQLWarningOrErrorList(ex); 
+                errorList = new SQLWarningOrErrorList(ex);
                 returnCode = errorList.getReturnCode();
             }
-            sqlQueryType = SqlUtils.getSqlStmtType(sqlString);
+            if (sqlString.isEmpty() == false)
+                sqlQueryType = SqlUtils.getSqlStmtType(sqlString);
+            else
+                sqlQueryType = SqlUtils.getSqlStmtType(sqlStmtType);
 //
 //===================calculate length of output ByteBuffer========================
 //
+            if(LOG.isDebugEnabled())
+                LOG.debug(serverWorkerName + ". calculate length of output ByteBuffer");
             bbHeader.clear();
             bbBody.clear();
 //
 // check if ByteBuffer is big enough for output
-//  
-            int dataLength = ServerConstants.INT_FIELD_SIZE;                 //returnCode
+//
+            TrafResultSet trs = null;
+
+            int dataLength = ServerConstants.INT_FIELD_SIZE;//returnCode
             if (errorList != null)
                 dataLength += errorList.lengthOfData();
             else
-                dataLength += ServerConstants.INT_FIELD_SIZE;             //totalErrorLength = 0
-            
+                dataLength += ServerConstants.INT_FIELD_SIZE;//totalErrorLength = 0
+
             if (outDescList != null)
                 dataLength += outDescList.lengthOfData();
             else
-                dataLength += ServerConstants.INT_FIELD_SIZE;             //outDescLength = 0
-            
-            dataLength += ServerConstants.INT_FIELD_SIZE;                 //rowsAffected
-            dataLength += ServerConstants.INT_FIELD_SIZE;                 //sqlQueryType
-            dataLength += ServerConstants.INT_FIELD_SIZE;                 //estimatedCost
-            dataLength += ByteBufferUtils.lengthOfByteArray(outValues); //outValues
-            
-            dataLength += ServerConstants.INT_FIELD_SIZE;                 //numResultSets
-            if (numResultSets > 0) {
-                for (int i = 0; i < numResultSets; i++) {
-                    dataLength += ServerConstants.INT_FIELD_SIZE;         //stmt_handle
-                    dataLength += ByteBufferUtils.lengthOfString(stmtLabels[i]); //stmtLabels
-                    dataLength += ServerConstants.INT_FIELD_SIZE;         //stmt_label_charset
-                    
-                    if (resultSetDescList != null)
-                        dataLength += resultSetDescList.lengthOfData();
-                    else
-                        dataLength += ServerConstants.INT_FIELD_SIZE;
-                    
-                    dataLength += ByteBufferUtils.lengthOfString(proxySyntax[i]); //proxySyntax[i]
+                dataLength += ServerConstants.INT_FIELD_SIZE;//outDescLength = 0
+
+            dataLength += ServerConstants.INT_FIELD_SIZE;//rowsAffected
+            dataLength += ServerConstants.INT_FIELD_SIZE;//sqlQueryType
+            dataLength += ServerConstants.INT_FIELD_SIZE;//estimatedCost
+            dataLength += ByteBufferUtils.lengthOfByteArray(outValues);//outValues
+
+            dataLength += ServerConstants.INT_FIELD_SIZE;// SPJ Result Sets
+            if (resultSetCount > 0) {
+                boolean bNextResultSet = true;
+                trafStmt.setFirstTResultSet();
+                while (bNextResultSet) {
+                    trs = trafStmt.getTrafResultSet();
+                    dataLength += trs.lengthOfData();
+                    bNextResultSet = trafStmt.getNextTResultSet();
                 }
             }
             dataLength += ByteBufferUtils.lengthOfString(singleSyntax);
-            
+
             int availableBuffer = bbBody.capacity() - bbBody.position();
             if(LOG.isDebugEnabled())
                 LOG.debug(serverWorkerName + ". dataLength :" + dataLength + " availableBuffer :" + availableBuffer);
             if (dataLength > availableBuffer )
                 bbBody = ByteBufferUtils.increaseCapacity(bbBody, dataLength > ServerConstants.BODY_SIZE ? dataLength : ServerConstants.BODY_SIZE );
-
+//
 //===================== build output ==============================================
+//
+            if(LOG.isDebugEnabled()) {
+                LOG.debug(serverWorkerName + ". returnCode :" + returnCode);
+                LOG.debug(serverWorkerName + ". errorList :" + errorList);
+                LOG.debug(serverWorkerName + ". outDescList :" + outDescList);
+                LOG.debug(serverWorkerName + ". rowsAffected :" + rowsAffected);
+                LOG.debug(serverWorkerName + ". sqlQueryType :" + sqlQueryType);
+                LOG.debug(serverWorkerName + ". estimatedCost :" + estimatedCost);
+                LOG.debug(serverWorkerName + ". outValues :" + outValues);
+                LOG.debug(serverWorkerName + ". SPJ Result Sets :" + resultSetCount);
+                LOG.debug(serverWorkerName + ". singleSyntax :" + singleSyntax);
+            }
             bbBody.putInt(returnCode);
             if (errorList != null)
                 errorList.insertIntoByteBuffer(bbBody);
             else
                 bbBody.putInt(0);
 
-            if (outDescList != null){
+            if (outDescList != null) {
                 outDescList.insertIntoByteBuffer(bbBody);
             } else
                 bbBody.putInt(0);
-                
+
             ByteBufferUtils.insertUInt(rowsAffected, bbBody);
             bbBody.putInt(sqlQueryType);
             bbBody.putInt(estimatedCost);
-            ByteBufferUtils.insertByteArray(outValues, bbBody);     //outValues
-            bbBody.putInt(numResultSets);
-
-            if (numResultSets > 0) {
-                for (int i = 0; i < numResultSets; i++) {
-                    bbBody.putInt(0); // int stmt_handle - ignored
-                    ByteBufferUtils.insertString(stmtLabels[i], bbBody);
-                    bbBody.putInt(0); // long stmt_label_charset - ignored
-                    
-                    if (resultSetDescList != null)
-                         resultSetDescList.insertIntoByteBuffer(bbBody);
-                    else
-                        bbBody.putInt(0);
-                    
-                     ByteBufferUtils.insertString(proxySyntax[i], bbBody);
+            ByteBufferUtils.insertByteArray(outValues, bbBody); //outValues
+            bbBody.putInt(resultSetCount);
+
+            if (resultSetCount > 0) {
+                boolean bNextResultSet = true;
+                trafStmt.setFirstTResultSet();
+                while (bNextResultSet) {
+                    trs = trafStmt.getTrafResultSet();
+                    trs.insertIntoByteBuffer(bbBody);
+                    bNextResultSet = trafStmt.getNextTResultSet();
                 }
+                trafStmt.setFirstTResultSet();
             }
             ByteBufferUtils.insertString(singleSyntax, bbBody);
 
             bbBody.flip();
-//=========================Update header================================ 
+//=========================Update header================================
             hdr.setTotalLength(bbBody.limit());
             hdr.insertIntoByteBuffer(bbHeader);
             bbHeader.flip();
@@ -385,11 +439,11 @@ public class ServerApiSqlExecute {
             clientData.setByteBufferArray(bbHeader, bbBody);
             clientData.setHdr(hdr);
             clientData.setRequest(ServerConstants.REQUST_WRITE_READ);
-            
-        } catch (UnsupportedEncodingException ue){
+
+        } catch (UnsupportedEncodingException ue) {
             LOG.error(serverWorkerName + ". Execute.UnsupportedEncodingException :" + ue);
             clientData.setRequestAndDisconnect();
-        } catch (Exception e){
+        } catch (Exception e) {
             LOG.error(serverWorkerName + ". Execute.Exception :" + e);
             clientData.setRequestAndDisconnect();
         }
@@ -397,11 +451,8 @@ public class ServerApiSqlExecute {
         return clientData;
     }
 //===================================================================================
-// get the column value data from Execute2 in String format
-    ByteBuffer setInpParams(PreparedStatement pstmt, Descriptor2List inpDescList, int paramRowCount, int paramNumber, int rowNumber, ByteBuffer bbBody, long startOffset) throws SQLException, ParseException, UnsupportedEncodingException {
-        int param = paramNumber + 1;
-        Descriptor2[] descArray = null;
-        Descriptor2 desc = null;
+//
+    ByteBuffer setData(Descriptor2 paramDesc, int paramRowCount, int param, int row, ByteBuffer bbBody, long startOffset) throws SQLException, ParseException, UnsupportedEncodingException {
         int paramLength = 0;
 
         String tmpStr = "";
@@ -420,44 +471,45 @@ public class ServerApiSqlExecute {
         long nanoSeconds;
         String charSet = "";
 
-        descArray = inpDescList.getDescriptors2();
-        desc = descArray[paramNumber];
-
-        int precision = desc.getPrecision();
-        int scale = desc.getScale();
-        int datetimeCode = desc.getDatetimeCode();
-        int FSDataType = desc.getFsDataType();
-        int OdbcDataType = desc.getOdbcDataType();
-        int dataCharSet = desc.getSqlCharset();
-        int dataLength = desc.getMaxLen();
-        int dataType = desc.getDataType();
+        int precision = paramDesc.getPrecision();
+        int scale = paramDesc.getScale();
+        int datetimeCode = paramDesc.getDatetimeCode();
+        int FSDataType = paramDesc.getFsDataType();
+        int OdbcDataType = paramDesc.getOdbcDataType();
+        int dataCharSet = paramDesc.getSqlCharset();
+        int dataLength = paramDesc.getMaxLen();
+        int dataType = paramDesc.getDataType();
 
         // setup the offsets
-        int noNullValue = desc.getNoNullValue();
-        int nullValue = desc.getNullValue();
+        int noNullValue = paramDesc.getNoNullValue();
+        int nullValue = paramDesc.getNullValue();
         long nullOffset = 0L;
         long noNullOffset = 0L;
-        
+
         if (dataType == ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH) {
             dataLength += 2;
 
             if (dataLength % 2 != 0)
                 dataLength++;
         }
-        if (nullValue != -1){
-            nullValue = (nullValue * paramRowCount) + (rowNumber * 2);
+        if(LOG.isDebugEnabled())
+            LOG.debug("nullValue :"+ nullValue);
+        if (nullValue != -1) {
+            nullValue = (nullValue * paramRowCount) + (row * 2);
             nullOffset = startOffset + nullValue;
             bbBody.position((int)nullOffset);
             short isNull = bbBody.getShort();
-            if ( isNull == -1){
-                pstmt.setObject(param, null);
+            if(LOG.isDebugEnabled())
+                LOG.debug("isNull :"+ isNull);
+            if ( isNull == -1) {
+                if (isSpj == true) cstmt.setObject(param,null); else pstmt.setObject(param,null);
                 return bbBody;
             }
         }
-        noNullValue = (noNullValue * paramRowCount) + (rowNumber * dataLength);
+        noNullValue = (noNullValue * paramRowCount) + (row * dataLength);
         noNullOffset = startOffset + noNullValue;
         bbBody.position((int)noNullOffset);
-        
+
         if(LOG.isDebugEnabled())
             LOG.debug("[" + param + "] noNullOffset :"+ noNullOffset + " noNullValue :" + noNullValue);
 
@@ -465,179 +517,337 @@ public class ServerApiSqlExecute {
             charSet = "UTF-16LE";
         else
             charSet = SqlUtils.getCharsetName(dataCharSet);
-        
+
         switch (dataType) {
-        case ServerConstants.SQLTYPECODE_CHAR:
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_CHAR");
-            tbuffer = new byte[dataLength];
-            bbBody.get(tbuffer, 0, dataLength);
-            retObj = new String(tbuffer, charSet);
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_CHAR length :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_VARCHAR:
-        case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
-            if(LOG.isDebugEnabled())
-                ByteBufferUtils.toHexString("VARCHAR/VARCHAR_LONG", bbBody, (dataLength > 100 ? 100 : dataLength));
-            tbuffer = new byte[dataLength];
-            bbBody.get(tbuffer, 0, dataLength);
-            retObj = new String(tbuffer, charSet);
-            if(LOG.isDebugEnabled()){
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_VARCHAR len :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-                LOG.debug(" retObj :" + Arrays.toString(((String)retObj).getBytes()));
-            }
-            break;
-        case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:
-            if(LOG.isDebugEnabled())
-                ByteBufferUtils.toHexString("VARCHAR_WITH_LENGTH", bbBody, (dataLength > 100 ? 100 : dataLength));
-            boolean shortLength = precision < Math.pow(2, 15);
-            int dataOffset = (shortLength) ? 2 : 4;
-            dataLength = (shortLength) ? bbBody.getShort() : bbBody.getInt();
-            tbuffer = new byte[dataLength];
-            bbBody.get(tbuffer, 0, dataLength);
-            retObj = new String(tbuffer, charSet);
-            if(LOG.isDebugEnabled()){
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_VARCHAR len :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-                LOG.debug(" retObj :" + Arrays.toString(((String)retObj).getBytes()));
-            }
-            break;
-        case ServerConstants.SQLTYPECODE_INTERVAL:
-            tbuffer = new byte[dataLength];
-            bbBody.get(tbuffer);
-            retObj =  new String(tbuffer);
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_INTERVAL dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_DATETIME:
-            switch (datetimeCode) {
-            case ServerConstants.SQLDTCODE_DATE:
+            case ServerConstants.SQLTYPECODE_CHAR:
+                if(LOG.isDebugEnabled())
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_CHAR");
                 tbuffer = new byte[dataLength];
-                bbBody.get(tbuffer);
-                retObj = java.sql.Date.valueOf((new String(tbuffer)).trim());
+                bbBody.get(tbuffer, 0, dataLength);
+                retObj = new String(tbuffer, charSet);
                 if(LOG.isDebugEnabled())
-                    LOG.debug("["+ param + "] dataType :SQLDTCODE_DATE dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_CHAR length :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                break;
+            case ServerConstants.SQLTYPECODE_VARCHAR:
+            case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
+                if(LOG.isDebugEnabled())
+                    ByteBufferUtils.toHexString("VARCHAR/VARCHAR_LONG", bbBody, (dataLength > 100 ? 100 : dataLength));
+                tbuffer = new byte[dataLength];
+                bbBody.get(tbuffer, 0, dataLength);
+                retObj = new String(tbuffer, charSet);
+                if(LOG.isDebugEnabled()) {
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_VARCHAR len :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                    LOG.debug(" retObj :" + Arrays.toString(((String)retObj).getBytes()));
+                }
+                break;
+            case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:
+                if(LOG.isDebugEnabled())
+                    ByteBufferUtils.toHexString("VARCHAR_WITH_LENGTH", bbBody, (dataLength > 100 ? 100 : dataLength));
+                boolean shortLength = precision < Math.pow(2, 15);
+                int dataOffset = (shortLength) ? 2 : 4;
+                dataLength = (shortLength) ? bbBody.getShort() : bbBody.getInt();
+                tbuffer = new byte[dataLength];
+                bbBody.get(tbuffer, 0, dataLength);
+                retObj = new String(tbuffer, charSet);
+                if(LOG.isDebugEnabled()) {
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_VARCHAR len :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                    LOG.debug(" retObj :" + Arrays.toString(((String)retObj).getBytes()));
+                }
                 break;
-            case ServerConstants.SQLDTCODE_TIMESTAMP:
+            case ServerConstants.SQLTYPECODE_INTERVAL:
                 tbuffer = new byte[dataLength];
                 bbBody.get(tbuffer);
-                retObj = Timestamp.valueOf((new String(tbuffer)).trim());
+                retObj = new String(tbuffer);
                 if(LOG.isDebugEnabled())
-                    LOG.debug("["+ param + "] dataType :SQLDTCODE_TIMESTAMP dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_INTERVAL dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                break;
+            case ServerConstants.SQLTYPECODE_DATETIME:
+                switch (datetimeCode) {
+                    case ServerConstants.SQLDTCODE_DATE:
+                        tbuffer = new byte[dataLength];
+                        bbBody.get(tbuffer);
+                        retObj = java.sql.Date.valueOf((new String(tbuffer)).trim());
+                        if(LOG.isDebugEnabled())
+                            LOG.debug("["+ param + "] dataType :SQLDTCODE_DATE dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                        break;
+                    case ServerConstants.SQLDTCODE_TIMESTAMP:
+                        tbuffer = new byte[dataLength];
+                        bbBody.get(tbuffer);
+                        retObj = Timestamp.valueOf((new String(tbuffer)).trim());
+                        if(LOG.isDebugEnabled())
+                            LOG.debug("["+ param + "] dataType :SQLDTCODE_TIMESTAMP dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                        break;
+                    case ServerConstants.SQLDTCODE_TIME:
+                        if (OdbcDataType == java.sql.Types.OTHER) // For Desc.SQLDTCODE_HOUR_TO_FRACTION
+                        {
+                            tbuffer = new byte[dataLength];
+                            bbBody.get(tbuffer);
+                            retObj = new String((new String(tbuffer)).trim());
+                        } else {
+                            dataLength = ServerConstants.timeLength;
+                            tbuffer = new byte[dataLength];
+                            bbBody.get(tbuffer);
+                            retObj = Time.valueOf((new String(tbuffer)).trim());
+                        }
+                        if(LOG.isDebugEnabled())
+                            LOG.debug("["+ param + "] dataType :SQLDTCODE_TIME dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                        break;
+                    default:
+                        tbuffer = new byte[dataLength];
+                        bbBody.get(tbuffer);
+                        retObj = new String(tbuffer);
+                        if(LOG.isDebugEnabled())
+                            LOG.debug("["+ param + "] dataType :default dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                        break;
+                } // SQLTYPECODE_DATETIME
                 break;
-            case ServerConstants.SQLDTCODE_TIME:
-                if (OdbcDataType == java.sql.Types.OTHER) // For Desc.SQLDTCODE_HOUR_TO_FRACTION
-                {
-                    tbuffer = new byte[dataLength];
-                    bbBody.get(tbuffer);
-                    retObj = new String((new String(tbuffer)).trim());
+            case ServerConstants.SQLTYPECODE_SMALLINT:
+                short sValue = bbBody.getShort();
+                retObj = new Short(sValue);
+                if (scale > 0) {
+                    retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+                }
+                if(LOG.isDebugEnabled())
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_SMALLINT dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                break;
+            case ServerConstants.SQLTYPECODE_SMALLINT_UNSIGNED:
+                int signedSValue = ByteBufferUtils.extractUShort(bbBody);
+                if (scale > 0) {
+                    tmpbd = new BigDecimal(new BigInteger(String.valueOf(signedSValue)), (int) scale);
                 } else {
-                    dataLength = ServerConstants.timeLength;
-                    tbuffer = new byte[dataLength];
-                    bbBody.get(tbuffer);
-                    retObj = Time.valueOf((new String(tbuffer)).trim());
+                    tmpbd = new BigDecimal(String.valueOf(signedSValue));
                 }
+                retObj = tmpbd;
                 if(LOG.isDebugEnabled())
-                    LOG.debug("["+ param + "] dataType :SQLDTCODE_TIME dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_SMALLINT_UNSIGNED dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
                 break;
-            default:
+            case ServerConstants.SQLTYPECODE_INTEGER:
+                retObj = new Integer(bbBody.getInt());
+                if (scale > 0) {
+                    retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+                }
+                if(LOG.isDebugEnabled())
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_INTEGER dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                break;
+            case ServerConstants.SQLTYPECODE_INTEGER_UNSIGNED:
+                retObj = new Long(ByteBufferUtils.extractUInt(bbBody));
+                if (scale > 0) {
+                    retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+                }
+                if(LOG.isDebugEnabled())
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_INTEGER_UNSIGNED dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
+                break;
+            case ServerConstants.SQLTYPECODE_LARGEINT:
+                retObj = new Long(bbBody.getLong());
+                if (scale > 0) {
+                    retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+                }
+                if(LOG.isDebugEnabled())
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_LARGEINT + dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
+                break;
+//--------------------------------- SQLTYPECODE_NUMERIC/SQLTYPECODE_NUMERIC_UNSIGNED converted to INTEGER using fsDataType_ (Descriptor2) ---------
+            case ServerConstants.SQLTYPECODE_NUMERIC:
+            case ServerConstants.SQLTYPECODE_NUMERIC_UNSIGNED:
+                if(LOG.isDebugEnabled())
+                    ByteBufferUtils.toHexString("SQLTYPECODE_NUMERIC", bbBody, (dataLength > 100 ? 100 : dataLength));
+                throw new SQLException("restricted_data_type");
+            case ServerConstants.SQLTYPECODE_DECIMAL:
+            case ServerConstants.SQLTYPECODE_DECIMAL_LARGE:
+            case ServerConstants.SQLTYPECODE_DECIMAL_UNSIGNED:
+            case ServerConstants.SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
+                String retStr;
                 tbuffer = new byte[dataLength];
                 bbBody.get(tbuffer);
-                retObj = new String(tbuffer);
+
+                byte firstByte = tbuffer[0];
+                byte sign = (byte) (firstByte & (byte) (0x80));
+                if (sign == (byte) (0x80)) {
+                    tbuffer[0] = (byte) (tbuffer[0] - (byte) (0x80));
+                    retStr = "-" + new String(tbuffer);
+                } else {
+                    retStr = new String(tbuffer);
+                }
+                retObj = new BigDecimal(new BigInteger(retStr), scale);
                 if(LOG.isDebugEnabled())
-                    LOG.debug("["+ param + "] dataType :default dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_DECIMAL dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
                 break;
-            }
-            break;
-        case ServerConstants.SQLTYPECODE_SMALLINT:
-            short sValue = bbBody.getShort();
-            retObj = new Short(sValue);
-            if (scale > 0) {
-                retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
-            }
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_SMALLINT dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_SMALLINT_UNSIGNED:
-            int signedSValue = ByteBufferUtils.extractUShort(bbBody);
-            if (scale > 0) {
-                tmpbd = new BigDecimal(new BigInteger(String.valueOf(signedSValue)), (int) scale);
+            case ServerConstants.SQLTYPECODE_REAL:
+                retObj = new Float(Float.intBitsToFloat(bbBody.getInt()));
+                if(LOG.isDebugEnabled())
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_REAL dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
+                break;
+            case ServerConstants.SQLTYPECODE_DOUBLE:
+            case ServerConstants.SQLTYPECODE_FLOAT:
+                retObj = new Double(Double.longBitsToDouble(bbBody.getLong()));
+                if(LOG.isDebugEnabled())
+                    LOG.debug("["+ param + "] dataType :SQLTYPECODE_DOUBLE dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
+                break;
+            case ServerConstants.SQLTYPECODE_BIT:
+            case ServerConstants.SQLTYPECODE_BITVAR:
+            case ServerConstants.SQLTYPECODE_BPINT_UNSIGNED:
+            default:
+                throw new SQLException("restricted_data_type");
+        } // dataType
+        if (isSpj == true) cstmt.setObject(param,retObj); else pstmt.setObject(param,retObj);
+        return bbBody;
+    }
+    byte[] buildOutValues(Descriptor2List paramDescList, byte[] outValues, int paramCount, CallableStatement cstmt, ByteOrder o) throws SQLException, UnsupportedEncodingException {
+
+        SQLMXCallableStatement sqlcall = (SQLMXCallableStatement)cstmt;
+        int paramOffset = 0;
+
+        if(LOG.isDebugEnabled())
+            LOG.debug(" buildOutValues paramCount :"+ paramCount);
+
+        for (int param = 1; param <= paramCount; param++) {
+            Descriptor2 dsc = paramDescList.getDescriptors2()[param - 1];
+            if ( dsc.getParamMode() == java.sql.ParameterMetaData.parameterModeIn) continue;
+
+            int noNullValueOffset = dsc.getNoNullValue();
+            int nullValueOffset = dsc.getNullValue();
+
+            if (nullValueOffset != -1)
+                nullValueOffset += paramOffset;
+            if (noNullValueOffset != -1)
+                noNullValueOffset += paramOffset;
+
+            byte[] sqlarray = sqlcall.getSQLBytes(param);
+            if (sqlarray == null) {
+                short value = -1;
+                outValues[(int)nullValueOffset] = (byte) ((value >>> 8) & 0xff);
+                outValues[(int)(nullValueOffset + 1)] = (byte) ((value) & 0xff);
             } else {
-                tmpbd = new BigDecimal(String.valueOf(signedSValue));
-            }
-            retObj = tmpbd;
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_SMALLINT_UNSIGNED dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_INTEGER:
-            retObj = new Integer(bbBody.getInt());
-            if (scale > 0) {
-                retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
-            }
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_INTEGER dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_INTEGER_UNSIGNED:
-            retObj = new Long(ByteBufferUtils.extractUInt(bbBody));
-            if (scale > 0) {
-                retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+                outValues = SqlUtils.formatSqlT4Output(dsc, sqlarray, noNullValueOffset, outValues, o);
             }
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_INTEGER_UNSIGNED dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_LARGEINT:
-            retObj = new Long(bbBody.getLong());
-            if (scale > 0) {
-                retObj = new BigDecimal(new BigInteger(retObj.toString()), scale);
+        }
+        return outValues;
+    }
+    void setMultipleResultSets(CallableStatement cstmt) throws SQLException {
+        resultSetCount = 0;
+        Descriptor2List outDescList = null;
+        ResultSet rs = null;
+        boolean moreResults = true;
+        while(moreResults) {
+            rs = cstmt.getResultSet();
+            addTResultSet(rs);
+            resultSetCount++;
+            moreResults = cstmt.getMoreResults();
+        }
+    }
+    void addTResultSet(ResultSet rs) throws SQLException {
+
+        ResultSetMetaData rsmd;
+        TResultSetMetaData trsmd;
+        SQLMXResultSetMetaData strsmd;
+
+        //-------------T2 desc fields-------------------
+        int sqlCharset_;
+        int odbcCharset_;
+        int sqlDataType_;
+        int dataType_;
+        short sqlPrecision_;
+        short sqlDatetimeCode_;
+        int sqlOctetLength_;
+        int isNullable_;
+        String name_;
+        int scale_;
+        int precision_;
+        boolean isSigned_;
+        boolean isCurrency_;
+        boolean isCaseSensitive_;
+        String catalogName_;
+        String schemaName_;
+        String tableName_;
+        int fsDataType_;
+        int intLeadPrec_;
+        int paramMode_;
+        int paramIndex_;
+        int paramPos_;
+
+        int odbcPrecision_;
+        int maxLen_;
+
+        int displaySize_;
+        String label_;
+
+        Descriptor2List descl = null;
+        int columnCount;
+
+        rsmd = rs.getMetaData();
+        columnCount = rsmd.getColumnCount();
+
+        if (columnCount > 0) {
+            strsmd = (SQLMXResultSetMetaData)rsmd;
+            outDescList = new Descriptor2List(columnCount,false);
+
+            for (int column = 1; column <= columnCount; column++) {
+                sqlCharset_ = strsmd.getSqlCharset(column);
+                odbcCharset_ = strsmd.getOdbcCharset(column);
+                sqlDataType_ = strsmd.getSqlDataType(column);
+                dataType_ = strsmd.getDataType(column);
+                sqlPrecision_ = strsmd.getSqlPrecision(column);
+                sqlDatetimeCode_ = strsmd.getSqlDatetimeCode(column);
+                sqlOctetLength_ = strsmd.getSqlOctetLength(column);
+                isNullable_ = strsmd.getIsNullable(column);
+                name_ = strsmd.getName(column);
+                scale_ = strsmd.getScale(column);
+                precision_ = strsmd.getPrecision(column);
+                isSigned_ = strsmd.getIsSigned(column);
+                isCurrency_ = strsmd.getIsCurrency(column);
+                isCaseSensitive_ = strsmd.getIsCaseSensitive(column);
+                catalogName_ = strsmd.getCatalogName(column);
+                schemaName_ = strsmd.getSchemaName(column);
+                tableName_ = strsmd.getTableName(column);
+                fsDataType_ = strsmd.getFsDataType(column);
+                intLeadPrec_ = strsmd.getIntLeadPrec(column);
+                paramMode_ = strsmd.getMode(column);
+                paramIndex_ = strsmd.getIndex(column);
+                paramPos_ = strsmd.getPos(column);
+
+                odbcPrecision_ = strsmd.getOdbcPrecision(column);
+                maxLen_ = strsmd.getMaxLen(column);
+
+                displaySize_ = strsmd.getDisplaySize(column);
+                label_ = strsmd.getLabel(column);
+
+                Descriptor2 outDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
+                        sqlOctetLength_,isNullable_,name_,scale_,precision_,isSigned_,
+                        isCurrency_,isCaseSensitive_,catalogName_,schemaName_,tableName_,
+                        fsDataType_,intLeadPrec_,paramMode_,paramIndex_,paramPos_,odbcPrecision_,
+                        maxLen_,displaySize_,label_, false);
+                outDescList.addDescriptor(column, outDesc);
             }
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_LARGEINT + dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
-            break;
-//--------------------------------- SQLTYPECODE_NUMERIC/SQLTYPECODE_NUMERIC_UNSIGNED converted to INTEGER using fsDataType_ (Descriptor2) --------- 
-        case ServerConstants.SQLTYPECODE_NUMERIC:
-        case ServerConstants.SQLTYPECODE_NUMERIC_UNSIGNED:
-            if(LOG.isDebugEnabled())
-                ByteBufferUtils.toHexString("SQLTYPECODE_NUMERIC", bbBody, (dataLength > 100 ? 100 : dataLength));
-            throw new SQLException("restricted_data_type");
-        case ServerConstants.SQLTYPECODE_DECIMAL:
-        case ServerConstants.SQLTYPECODE_DECIMAL_LARGE:
-        case ServerConstants.SQLTYPECODE_DECIMAL_UNSIGNED:
-        case ServerConstants.SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
-            String retStr;
-        
-            tbuffer = new byte[dataLength];
-            bbBody.get(tbuffer);
-
-            byte firstByte = tbuffer[0];
-            byte sign = (byte) (firstByte & (byte) (0x80));
-            if (sign == (byte) (0x80)) {
-                tbuffer[0] = (byte) (tbuffer[0] - (byte) (0x80));
-                retStr = "-" + new String(tbuffer);
-            } else {
-                retStr = new String(tbuffer);
+            if(LOG.isDebugEnabled()) {
+                for (int column = 1; column <= columnCount; column++) {
+                    Descriptor2 dsc = outDescList.getDescriptors2()[column-1];
+                    LOG.debug(serverWorkerName + ". [" + column + "] Column descriptor -------------" );
+                    LOG.debug(serverWorkerName + ". oldFormat " + column + " :" + dsc.getOldFormat());
+                    LOG.debug(serverWorkerName + ". noNullValue " + column + " :" + dsc.getNoNullValue());
+                    LOG.debug(serverWorkerName + ". nullValue " + column + " :" + dsc.getNullValue());
+                    LOG.debug(serverWorkerName + ". version " + column + " :" + dsc.getVersion());
+                    LOG.debug(serverWorkerName + ". dataType " + column + " :" + SqlUtils.getDataType(dsc.getDataType()));
+                    LOG.debug(serverWorkerName + ". datetimeCode " + column + " :" + dsc.getDatetimeCode());
+                    LOG.debug(serverWorkerName + ". maxLen " + column + " :" + dsc.getMaxLen());
+                    LOG.debug(serverWorkerName + ". precision " + column + " :" + dsc.getPrecision());
+                    LOG.debug(serverWorkerName + ". scale " + column + " :" + dsc.getScale());
+                    LOG.debug(serverWorkerName + ". nullInfo " + column + " :" + dsc.getNullInfo());
+                    LOG.debug(serverWorkerName + ". signed " + column + " :" + dsc.getSigned());
+                    LOG.debug(serverWorkerName + ". odbcDataType " + column + " :" + dsc.getOdbcDataType());
+                    LOG.debug(serverWorkerName + ". odbcPrecision " + column + " :" + dsc.getOdbcPrecision());
+                    LOG.debug(serverWorkerName + ". sqlCharset " + column + " :" + SqlUtils.getCharsetName(dsc.getSqlCharset()) + "[" + dsc.getSqlCharset() + "]");
+                    LOG.debug(serverWorkerName + ". odbcCharset " + column + " :" + SqlUtils.getCharsetName(dsc.getOdbcCharset()) + "[" + dsc.getOdbcCharset() + "]");
+                    LOG.debug(serverWorkerName + ". colHeadingNm " + column + " :" + dsc.getColHeadingNm());
+                    LOG.debug(serverWorkerName + ". tableName " + column + " :" + dsc.getTableName());
+                    LOG.debug(serverWorkerName + ". schemaName " + column + " :" + dsc.getSchemaName());
+                    LOG.debug(serverWorkerName + ". headingName " + column + " :" + dsc.getHeadingName());
+                    LOG.debug(serverWorkerName + ". intLeadPrec " + column + " :" + dsc.getParamMode());
+                    LOG.debug(serverWorkerName + ". paramMode " + column + " :" + dsc.getColHeadingNm());
+                    LOG.debug(serverWorkerName + ". varLength " + column + " :" + dsc.getVarLength());
+                    LOG.debug(serverWorkerName + ". Column descriptor End-------------");
+                }
             }
-            retObj = new BigDecimal(new BigInteger(retStr), scale);
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_DECIMAL dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_REAL:
-            retObj = new Float(Float.intBitsToFloat(bbBody.getInt()));
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_REAL dataLength :" + dataLength + " scale :" + scale + " retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_DOUBLE:
-        case ServerConstants.SQLTYPECODE_FLOAT:
-            retObj = new Double(Double.longBitsToDouble(bbBody.getLong()));
-            if(LOG.isDebugEnabled())
-                LOG.debug("["+ param + "] dataType :SQLTYPECODE_DOUBLE dataLength :" + dataLength + " scale :" + scale + "  retObj :" + retObj);
-            break;
-        case ServerConstants.SQLTYPECODE_BIT:
-        case ServerConstants.SQLTYPECODE_BITVAR:
-        case ServerConstants.SQLTYPECODE_BPINT_UNSIGNED:
-        default:
-            throw new SQLException("restricted_data_type");
         }
-        pstmt.setObject(param,retObj);
-        return bbBody;
-    } // end getExecute2FetchString
-}
\ No newline at end of file
+        if (columnCount > 0)
+            trafStmt.addTResultSet(new TrafResultSet(rs, 0, stmtLabel, 0, outDescList,""));
+    }
+}


[6/6] incubator-trafodion git commit: Merge remote branch 'origin/pr/111/head' into mrg_61

Posted by su...@apache.org.
Merge remote branch 'origin/pr/111/head' into mrg_61


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/df76babe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/df76babe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/df76babe

Branch: refs/heads/master
Commit: df76babe98897990fe34370bf2fc7416a88af864
Parents: a751675 dd15115
Author: Suresh Subbiah <su...@apache.org>
Authored: Sat Oct 10 04:41:33 2015 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Sat Oct 10 04:41:33 2015 +0000

----------------------------------------------------------------------
 .../trafodion/dcs/servermt/ServerConstants.java |  64 +-
 .../serverDriverInputOutput/Descriptor2.java    | 260 +++---
 .../Descriptor2List.java                        | 269 +++---
 .../SQLWarningOrError.java                      |   7 +-
 .../serverDriverInputOutput/Version.java        |  18 +
 .../serverHandler/ServerApiGetCatalogs.java     | 175 ++--
 .../serverHandler/ServerApiSqlExecDirect.java   | 182 ++--
 .../serverHandler/ServerApiSqlExecute.java      | 864 ++++++++++++-------
 .../serverHandler/ServerApiSqlFetch.java        | 627 +++++---------
 .../serverHandler/ServerApiSqlPrepare.java      | 207 ++---
 .../ServerApiSqlSetConnectAttr.java             |  39 +-
 .../dcs/servermt/serverSql/TrafConnection.java  | 137 +--
 .../dcs/servermt/serverSql/TrafResultSet.java   | 154 ++++
 .../dcs/servermt/serverSql/TrafStatement.java   | 212 +++--
 .../java/org/trafodion/dcs/util/SqlUtils.java   | 348 +++++++-
 15 files changed, 2029 insertions(+), 1534 deletions(-)
----------------------------------------------------------------------



[2/6] incubator-trafodion git commit: Delivering multithreaded code to support resultsets.

Posted by su...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlFetch.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlFetch.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlFetch.java
index f07e20d..dcf579d 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlFetch.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlFetch.java
@@ -54,7 +54,7 @@ public class ServerApiSqlFetch {
     private static final int odbc_SQLSvc_Fetch_SQLStillExecuting_exn_ = 6;
     private static final int odbc_SQLSvc_Fetch_SQLQueryCancelled_exn_ = 7;
     private static final int odbc_SQLSvc_Fetch_TransactionError_exn_ = 8;
-    
+
     private static final int dateLength = 10;
     private static final int timeLength = 8;
     private static final int timestampLength = 26;
@@ -73,7 +73,8 @@ public class ServerApiSqlFetch {
     private SQLMXResultSetMetaData strsmd;
     private TrafConnection trafConn;
     private TrafStatement trafStmt;
-    private Descriptor2List outDescList;
+    private TrafResultSet trafResultSet;
+    private Descriptor2List columnDescList;
 //----------------------------------------------
     private String stmtLabelBytes;
     private String cursorNameBytes;
@@ -88,7 +89,7 @@ public class ServerApiSqlFetch {
     private long maxRowLen;
     private String cursorName;
     private String stmtOptions;
-//=========================================    
+//===========================================
     private int returnCode;
     private SQLWarningOrErrorList errorList;
     private int rowsAffected;
@@ -101,10 +102,10 @@ public class ServerApiSqlFetch {
     private long curOutNullPos;
     private long rowOffset;
     private int curRowNumber;
-    private int outNumParam;
-    private int outLength;
+    private int columnCount;
+    private int columnLength;
 
-    ServerApiSqlFetch(int instance, int serverThread) {  
+    ServerApiSqlFetch(int instance, int serverThread) {
         this.instance = instance;
         this.serverThread = serverThread;
         serverWorkerName = ServerConstants.SERVER_WORKER_NAME + "_" + instance + "_" + serverThread;
@@ -122,8 +123,8 @@ public class ServerApiSqlFetch {
         maxRowLen = 0;
         cursorName = "";
         stmtOptions = "";
-        
-        returnCode = 0;
+
+        returnCode = ServerConstants.SQL_SUCCESS;
         errorList = null;
         rowsAffected = 0;
         outValuesFormat = 0;
@@ -131,7 +132,7 @@ public class ServerApiSqlFetch {
         stmtLabelBytes = "";
         cursorNameBytes = "";
         stmtOptionsBytes = "";
-        
+
         strsmd = null;
         sqlrs = null;
         sqlarray = null;
@@ -139,25 +140,25 @@ public class ServerApiSqlFetch {
         curOutPos = 0;
         curOutNullPos = 0;
         curRowNumber = 0;
-        outNumParam = 0;
-        outDescList = null;
+        columnCount = 0;
+        columnDescList = null;
     }
-    ClientData processApi(ClientData clientData) {  
+    ClientData processApi(ClientData clientData) {
         this.clientData = clientData;
         init();
-//        
+//
 // ==============process input ByteBuffer===========================
-// 
+//
         ByteBuffer bbHeader = clientData.bbHeader;
         ByteBuffer bbBody = clientData.bbBody;
         Header hdr = clientData.hdr;
 
         bbHeader.flip();
         bbBody.flip();
-        
+
         try {
             hdr.extractFromByteArray(bbHeader);
-            
+
             dialogueId =  bbBody.getInt();
             sqlAsyncEnable =  bbBody.getInt();
             queryTimeout =  bbBody.getInt();
@@ -187,195 +188,201 @@ public class ServerApiSqlFetch {
             }
 //=========================================================================
             trafConn = clientData.getTrafConnection();
-            trafStmt = trafConn.getTrafStatement(stmtLabel);
-            rs = trafStmt.getResultSet();
-            outDescList = trafStmt.getOutDescList();
-            
-            maxRowLen = trafStmt.getOutParamLength();
-            outNumParam = trafStmt.getOutNumberParams();
-            outDescList = trafStmt.getOutDescList();
-            
-            if(LOG.isDebugEnabled()){
-                LOG.debug(serverWorkerName + ". maxRowLen :" + maxRowLen);
-                LOG.debug(serverWorkerName + ". outNumParam :" + outNumParam);
+            trafStmt = trafConn.getTrafStatement(stmtLabel,stmtHandle);
+            trafResultSet = trafStmt.getTrafResultSet(); // get current result set
+
+            rs = trafResultSet.getResultSet();
+            if (trafResultSet.isClosed() == true){
+                if(true == trafStmt.getNextTResultSet()){
+                    trafResultSet = trafStmt.getTrafResultSet();
+                    rs = trafResultSet.getResultSet();
+                }
             }
-            returnCode = ServerConstants.SQL_SUCCESS;
-            boolean closeResultSet = false;
-            
+            if (trafResultSet.isClosed() == false){
+
+                columnDescList = trafResultSet.getColumnDescList();
+                maxRowLen = columnDescList.getVarLength();
+                columnCount = columnDescList.getDescCount();
+
+                if(LOG.isDebugEnabled()){
+                    LOG.debug(serverWorkerName + ". maxRowLen :" + maxRowLen);
+                    LOG.debug(serverWorkerName + ". columnCount :" + columnCount);
+                }
+                returnCode = ServerConstants.SQL_SUCCESS;
+                boolean closeResultSet = false;
+
 //=====================Process ServerApiSqlFetch===========================
-            if (outDescList.getOldFormat() == false){
-                try {
-                    while( rs != null){
-                        Descriptor2[] desc = outDescList.getDescriptors2();
-                        Descriptor2 dsc;
-                        int dataType = 0;
-                        int dataMaxLen = 0;
-                        sqlrs = (SQLMXResultSet)rs;
-                        if (false == rs.next()){
-                            closeResultSet = true; 
-                            if(LOG.isDebugEnabled())
-                                LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() false");
-                            break;
-                        }
-                        else{
-                            if(LOG.isDebugEnabled())
-                                LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() true");
-                        }
-                        if(totalOutLen == 0){
-                            totalOutLen = maxRowLen * maxRowCnt;
-                            outValues = new byte[(int)totalOutLen];
-                        }
-                        if(LOG.isDebugEnabled()){
-                            LOG.debug(serverWorkerName + ". curRowNumber :" + curRowNumber);
-                            LOG.debug(serverWorkerName + ". totalOutLen :" + totalOutLen);
-                        }
-                        rowOffset = maxRowLen * curRowNumber;
-                    
-                        for(int column = 1; column <= outNumParam; column++){
-                            dsc = desc[column - 1];
-                            int noNullValueOffset = dsc.getNoNullValue();
-                            int nullValueOffset = dsc.getNullValue();
-                            
-                            if (nullValueOffset != -1)
-                                nullValueOffset += rowOffset;
-                            if (noNullValueOffset != -1)
-                                noNullValueOffset += rowOffset;
-                            
-                            byte[] sqlarray = sqlrs.getSQLBytes(column);
-                            if (sqlarray == null) {
-                                short value = -1;
-                                outValues[(int)nullValueOffset] = (byte) ((value >>> 8) & 0xff);
-                                outValues[(int)(nullValueOffset + 1)] = (byte) ((value) & 0xff);
+                if (columnDescList.getOldFormat() == false){
+                    try {
+                        while( rs != null){
+                            Descriptor2[] desc = columnDescList.getDescriptors2();
+                            Descriptor2 dsc;
+                            int dataType = 0;
+                            int dataMaxLen = 0;
+                            sqlrs = (SQLMXResultSet)rs;
+                            if (false == rs.next()){
+                                closeResultSet = true;
+                                if(LOG.isDebugEnabled())
+                                    LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() false");
+                                break;
                             }
-                            else {
-                                outValues = formatSqlT4Output(dsc, sqlarray, noNullValueOffset, outValues, bbBody.order());
+                            else{
+                                if(LOG.isDebugEnabled())
+                                    LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() true");
                             }
+                            if(totalOutLen == 0){
+                                totalOutLen = maxRowLen * maxRowCnt;
+                                outValues = new byte[(int)totalOutLen];
+                            }
+                            rowOffset = maxRowLen * curRowNumber;
+
+                            if(LOG.isDebugEnabled()){
+                                LOG.debug(serverWorkerName + ". curRowNumber :" + curRowNumber + "  maxRowCnt :" + maxRowCnt);
+                                LOG.debug(serverWorkerName + ". totalOutLen :" + totalOutLen);
+                                LOG.debug(serverWorkerName + ". rowOffset :" + rowOffset);
+                            }
+
+                            for(int column = 1; column <= columnCount; column++){
+                                dsc = desc[column - 1];
+                                int noNullValueOffset = dsc.getNoNullValue();
+                                int nullValueOffset = dsc.getNullValue();
+
+                                if (nullValueOffset != -1)
+                                    nullValueOffset += rowOffset;
+                                if (noNullValueOffset != -1)
+                                    noNullValueOffset += rowOffset;
+
+                                byte[] sqlarray = sqlrs.getSQLBytes(column);
+                                if (sqlarray == null) {
+                                    short value = -1;
+                                    outValues[(int)nullValueOffset] = (byte) ((value >>> 8) & 0xff);
+                                    outValues[(int)(nullValueOffset + 1)] = (byte) ((value) & 0xff);
+                                }
+                                else {
+                                    outValues = SqlUtils.formatSqlT4Output(dsc, sqlarray, noNullValueOffset, outValues, bbBody.order());
+                                }
+                            }
+                            curRowNumber++;
+                            if (curRowNumber == maxRowCnt)
+                                break;
                         }
-                        curRowNumber++;
+                    } catch (SQLException ex){
+                        LOG.error(serverWorkerName + ". Fetch.SQLException " + ex);
+                        errorList = new SQLWarningOrErrorList(ex);
+                        returnCode = errorList.getReturnCode();
+                    }
+                    rowsAffected = curRowNumber;
+                    if (rowsAffected != maxRowCnt && rowsAffected != 0){
+                        int len = (int)(rowsAffected * maxRowLen);
                         if(LOG.isDebugEnabled()){
-                            LOG.debug(serverWorkerName + ". curRowNumber :" + curRowNumber + " maxRowCnt :" + maxRowCnt);
+                            LOG.debug(serverWorkerName + ". len :" + len);
                         }
-                        if (curRowNumber == maxRowCnt)
-                            break;
-                    }
-                } catch (SQLException ex){
-                    LOG.error(serverWorkerName + ". Fetch.SQLException " + ex);
-                    errorList = new SQLWarningOrErrorList(ex); 
-                    returnCode = errorList.getReturnCode();
-                }
-                rowsAffected = curRowNumber;
-                if (rowsAffected != maxRowCnt && rowsAffected != 0){
-                    int len = (int)(rowsAffected * maxRowLen);
-                    if(LOG.isDebugEnabled()){
-                        LOG.debug(serverWorkerName + ". len :" + len);
-                    }
-                    byte[] dst = new byte[len];
-                    System.arraycopy(outValues, 0, dst, 0, len);
-                    if(LOG.isDebugEnabled()){
-                        LOG.debug(serverWorkerName + ". dst :" + Arrays.toString(dst));
+                        byte[] dst = new byte[len];
+                        System.arraycopy(outValues, 0, dst, 0, len);
+                        if(LOG.isDebugEnabled()){
+                            LOG.debug(serverWorkerName + ". dst :" + Arrays.toString(dst));
+                        }
+                        outValues = dst;
                     }
-                    outValues = dst;
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". closeResultSet");
+                    if (closeResultSet == true)
+                        trafStmt.closeTResultSet();
                 }
-                if(LOG.isDebugEnabled())
-                    LOG.debug(serverWorkerName + ". closeResultSet before");
-                if (closeResultSet == true)         
-                    trafStmt.closeTResultSet();
-                if(LOG.isDebugEnabled())
-                    LOG.debug(serverWorkerName + ". closeResultSet after");
-            }
 //---------------------------------------------------------------------------------------------
-            else {
-                if(LOG.isDebugEnabled())
-                    LOG.debug(serverWorkerName + ". Processing old format result set");
-                int byteIndex = 0;
-                
-                try {
-                    while( rs != null){
-                        Descriptor2[] desc = outDescList.getDescriptors2();
-                        Descriptor2 dsc;
-                        int dataType = 0;
-                        int dataMaxLen = 0;
-                        sqlrs = (SQLMXResultSet)rs;
-                        if (false == rs.next()){
-                            closeResultSet = true; 
-                            if(LOG.isDebugEnabled())
-                                LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() false");
-                            break;
-                        }
-                        else{
-                            if(LOG.isDebugEnabled())
-                                LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() true");
-                        }
-                        if(totalOutLen == 0){
-                            byteIndex = 0;
-                            totalOutLen = maxRowLen * maxRowCnt;
-                            outValues = new byte[(int)totalOutLen];
-                        }
-                        byte[] sqlarray = null;
-                        short SQLDataInd = 0;
-                        
-                        for(int column = 1; column <= outNumParam; column++){
-                            dsc = desc[column - 1];
-                            sqlarray = sqlrs.getSQLBytes(column);
-                            if (sqlarray != null)
-                                SQLDataInd = 0;
-                            else 
-                                SQLDataInd = -1;
-                            
-                            outValues[byteIndex++] = (byte) (SQLDataInd);
-                            if (SQLDataInd == 0){    
-                                ByteBuffer tb = ByteBuffer.wrap(sqlarray).order(bbBody.order());
-                                int allocLength = sqlarray.length;
-                            
-                                switch (dsc.getDataType()) {
-                                case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:
-                                case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
-                                case ServerConstants.SQLTYPECODE_BITVAR:
-                                case ServerConstants.SQLTYPECODE_VARCHAR:
-                                    boolean shortLength = dsc.getPrecision() < Math.pow(2, 15);
-                                    allocLength = (shortLength) ? tb.getShort() + 2 : tb.getInt() + 4;
-                                    break;
-                                }
-                                System.arraycopy(sqlarray, 0, outValues, (int)byteIndex, allocLength);
-    
-                                byteIndex = byteIndex + allocLength;
-                                
-                                switch (dsc.getDataType()) {
-                                case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:
-                                case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
-                                case ServerConstants.SQLTYPECODE_BITVAR:
-                                case ServerConstants.SQLTYPECODE_CHAR:
-                                case ServerConstants.SQLTYPECODE_VARCHAR:
-                                    byteIndex++;
-                                    break;
+                else {
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". Processing old format result set");
+                    int byteIndex = 0;
+
+                    try {
+                        while( rs != null){
+                            Descriptor2[] desc = columnDescList.getDescriptors2();
+                            Descriptor2 dsc;
+                            int dataType = 0;
+                            int dataMaxLen = 0;
+                            sqlrs = (SQLMXResultSet)rs;
+                            if (false == rs.next()){
+                                closeResultSet = true;
+                                if(LOG.isDebugEnabled())
+                                    LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() false");
+                                break;
+                            }
+                            else{
+                                if(LOG.isDebugEnabled())
+                                    LOG.debug(serverWorkerName + ". T2 Fetch.rs.next() true");
+                            }
+                            if(totalOutLen == 0){
+                                byteIndex = 0;
+                                totalOutLen = maxRowLen * maxRowCnt;
+                                outValues = new byte[(int)totalOutLen];
+                            }
+                            byte[] sqlarray = null;
+                            short SQLDataInd = 0;
+
+                            for(int column = 1; column <= columnCount; column++){
+                                dsc = desc[column - 1];
+                                sqlarray = sqlrs.getSQLBytes(column);
+                                if (sqlarray != null)
+                                    SQLDataInd = 0;
+                                else
+                                    SQLDataInd = -1;
+
+                                outValues[byteIndex++] = (byte) (SQLDataInd);
+                                if (SQLDataInd == 0){
+                                    ByteBuffer tb = ByteBuffer.wrap(sqlarray).order(bbBody.order());
+                                    int allocLength = sqlarray.length;
+
+                                    switch (dsc.getDataType()) {
+                                    case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:
+                                    case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
+                                    case ServerConstants.SQLTYPECODE_BITVAR:
+                                    case ServerConstants.SQLTYPECODE_VARCHAR:
+                                        boolean shortLength = dsc.getPrecision() < Math.pow(2, 15);
+                                        allocLength = (shortLength) ? tb.getShort() + 2 : tb.getInt() + 4;
+                                        break;
+                                    }
+                                    System.arraycopy(sqlarray, 0, outValues, (int)byteIndex, allocLength);
+
+                                    byteIndex = byteIndex + allocLength;
+
+                                    switch (dsc.getDataType()) {
+                                    case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:
+                                    case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
+                                    case ServerConstants.SQLTYPECODE_BITVAR:
+                                    case ServerConstants.SQLTYPECODE_CHAR:
+                                    case ServerConstants.SQLTYPECODE_VARCHAR:
+                                        byteIndex++;
+                                        break;
+                                    }
                                 }
                             }
+                            curRowNumber++;
+                            if (curRowNumber == maxRowCnt)
+                                break;
                         }
-                        curRowNumber++;
-                        if (curRowNumber == maxRowCnt)
-                            break;
+                    } catch (SQLException ex){
+                        LOG.error(serverWorkerName + ". Fetch.SQLException " + ex);
+                        errorList = new SQLWarningOrErrorList(ex);
+                        returnCode = errorList.getReturnCode();
                     }
-                } catch (SQLException ex){
-                    LOG.error(serverWorkerName + ". Fetch.SQLException " + ex);
-                    errorList = new SQLWarningOrErrorList(ex); 
-                    returnCode = errorList.getReturnCode();
-                }
-                rowsAffected = curRowNumber;
-                if (rowsAffected != maxRowCnt && rowsAffected != 0){
-                    int len = byteIndex;
-                    if(LOG.isDebugEnabled()){
-                        LOG.debug(serverWorkerName + ". len :" + len);
+                    rowsAffected = curRowNumber;
+                    if (rowsAffected != maxRowCnt && rowsAffected != 0){
+                        int len = byteIndex;
+                        if(LOG.isDebugEnabled()){
+                            LOG.debug(serverWorkerName + ". len :" + len);
+                        }
+                        byte[] dst = new byte[len];
+                        System.arraycopy(outValues, 0, dst, 0, len);
+                        outValues = dst;
                     }
-                    byte[] dst = new byte[len];
-                    System.arraycopy(outValues, 0, dst, 0, len);
-                    outValues = dst;
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". closeResultSet before");
+                    if (closeResultSet == true)
+                        trafResultSet.closeTResultSet();
+                    if(LOG.isDebugEnabled())
+                        LOG.debug(serverWorkerName + ". closeResultSet after");
                 }
-                if(LOG.isDebugEnabled())
-                    LOG.debug(serverWorkerName + ". closeResultSet before");
-                if (closeResultSet == true)         
-                    trafStmt.closeTResultSet();
-                if(LOG.isDebugEnabled())
-                    LOG.debug(serverWorkerName + ". closeResultSet after");
             }
 //
 //===================calculate length of output ByteBuffer========================
@@ -384,15 +391,15 @@ public class ServerApiSqlFetch {
             bbBody.clear();
 //
 // check if ByteBuffer is big enough for output
-//      
+//
             if(rowsAffected == 0 && returnCode == ServerConstants.SQL_SUCCESS){
                 returnCode = ServerConstants.SQL_NO_DATA_FOUND;
             }
             if(LOG.isDebugEnabled())
                 LOG.debug(serverWorkerName + ". returnCode :" + returnCode);
-            
+
             int dataLength = ServerConstants.INT_FIELD_SIZE;                 //returnCode
-            
+
             if (returnCode != ServerConstants.SQL_SUCCESS && returnCode != ServerConstants.SQL_NO_DATA_FOUND) {
                 dataLength += ServerConstants.INT_FIELD_SIZE;                 //totalErrorLength
                 if (errorList != null)
@@ -404,7 +411,7 @@ public class ServerApiSqlFetch {
             dataLength += ServerConstants.INT_FIELD_SIZE;                 //outValuesFormat
             if (returnCode == ServerConstants.SQL_SUCCESS || returnCode == ServerConstants.SQL_SUCCESS_WITH_INFO)
                 dataLength += ByteBufferUtils.lengthOfByteArray(outValues);
-                
+
             int availableBuffer = bbBody.capacity() - bbBody.position();
             if(LOG.isDebugEnabled())
                 LOG.debug(serverWorkerName + ". dataLength :" + dataLength + " availableBuffer :" + availableBuffer);
@@ -413,7 +420,7 @@ public class ServerApiSqlFetch {
 
 //===================== build output ==============================================
             bbBody.putInt(returnCode);
-            
+
             if (returnCode != ServerConstants.SQL_SUCCESS && returnCode != ServerConstants.SQL_NO_DATA_FOUND) {
                 if (errorList != null)
                     errorList.insertIntoByteBuffer(bbBody);
@@ -424,9 +431,9 @@ public class ServerApiSqlFetch {
             bbBody.putInt(ServerConstants.ROWWISE_ROWSETS);
             if (returnCode == ServerConstants.SQL_SUCCESS || returnCode == ServerConstants.SQL_SUCCESS_WITH_INFO)
                 ByteBufferUtils.insertByteArray(outValues, bbBody);
-            
+
             bbBody.flip();
-//=========================Update header================================ 
+//=========================Update header================================
             hdr.setTotalLength(bbBody.limit());
             hdr.insertIntoByteBuffer(bbHeader);
             bbHeader.flip();
@@ -444,231 +451,7 @@ public class ServerApiSqlFetch {
         if(LOG.isDebugEnabled())
             LOG.debug(serverWorkerName + ". Fetch exit: returnCode :" + returnCode + " rowsAffected :" + rowsAffected );
         reset();
-        
+
         return clientData;
     }
-    byte[] formatSqlT4Output(Descriptor2 dsc, byte[] sqlarray, long curOutPos, byte[] outValues, ByteOrder bo) throws UnsupportedEncodingException{
-        
-        ByteBuffer bb = null;
-        byte[] dst = null;
-        int len = 0;
-        int offset = 0;
-        int insNull = 0;
-
-        String[] stDate = null;
-        String[] stTime = null;
-        String[] stTimestamp = null;
-        String[] stNanos = null;
-        Integer year = 0;
-        Integer month = 0;
-        Integer day = 0;
-        Integer hour = 0;
-        Integer minutes = 0;
-        Integer seconds = 0;
-        Integer nanos = 0;
-
-        String setString = "";
-        short setShort = 0;
-        int setInt = 0;
-        long setLong = 0L;
-        boolean setSign = false;
-        String charSet = "";
-        
-        int precision = dsc.getPrecision();
-        int scale = dsc.getScale();
-        int datetimeCode = dsc.getDatetimeCode();
-        int FSDataType = dsc.getFsDataType();
-        int OdbcDataType = dsc.getOdbcDataType();
-        int dataCharSet = dsc.getSqlCharset();
-        int length = dsc.getMaxLen();
-        int dataType = dsc.getDataType();
-        
-        if(dataCharSet == SqlUtils.SQLCHARSETCODE_UNICODE)
-            charSet = "UTF-16LE";
-        else
-            charSet = SqlUtils.getCharsetName(dataCharSet);
-        
-        len = sqlarray.length;
-        ByteBuffer tb = ByteBuffer.wrap(sqlarray).order(bo);
-        
-        switch(dataType){
-        case ServerConstants.SQLTYPECODE_CHAR:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_CHAR :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_VARCHAR:
-        case ServerConstants.SQLTYPECODE_VARCHAR_LONG:
-        case ServerConstants.SQLTYPECODE_VARCHAR_WITH_LENGTH:       //-601
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_VARCHAR :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_DATETIME:
-            LOG.debug("formatSqlT4Output: SQLTYPECODE_DATETIME :" + Arrays.toString(sqlarray));
-            switch(datetimeCode){
-                case ServerConstants.SQLDTCODE_DATE:
-                case ServerConstants.SQLDTCODE_TIME:
-                case ServerConstants.SQLDTCODE_TIMESTAMP:
-                    len = tb.getShort();
-                    dst = new byte[len];
-                    System.arraycopy(sqlarray, 2, dst, 0, len);
-                    setString = new String(dst,"UTF8");
-                    tb.clear();
-                    switch(datetimeCode){
-                        case ServerConstants.SQLDTCODE_DATE:
-                            stDate = setString.split("-");
-                            year = Integer.valueOf(stDate[0]);
-                            month = Integer.valueOf(stDate[1]);
-                            day = Integer.valueOf(stDate[2]);
-                            tb.putShort(year.shortValue());
-                            tb.put(month.byteValue());
-                            tb.put(day.byteValue());
-                            break;
-                        case ServerConstants.SQLDTCODE_TIME:
-                            stTime = setString.split(":");
-                            hour = Integer.valueOf(stTime[0]);
-                            minutes = Integer.valueOf(stTime[1]);
-                            seconds = Integer.valueOf(stTime[2]);
-                            tb.put(hour.byteValue());
-                            tb.put(minutes.byteValue());
-                            tb.put(seconds.byteValue());
-                            break;
-                        case ServerConstants.SQLDTCODE_TIMESTAMP:
-                            stTimestamp = setString.split(" ");
-                            stDate = stTimestamp[0].split("-");
-                            stNanos = stTimestamp[1].split("\\.");
-                            stTime = stNanos[0].split(":");
-                            year = Integer.valueOf(stDate[0]);
-                            month = Integer.valueOf(stDate[1]);
-                            day = Integer.valueOf(stDate[2]);
-                            hour = Integer.valueOf(stTime[0]);
-                            minutes = Integer.valueOf(stTime[1]);
-                            seconds = Integer.valueOf(stTime[2]);
-                            nanos = Integer.valueOf(stNanos[1]);
-                            tb.putShort(year.shortValue());
-                            tb.put(month.byteValue());
-                            tb.put(day.byteValue());
-                            tb.put(hour.byteValue());
-                            tb.put(minutes.byteValue());
-                            tb.put(seconds.byteValue());
-                            tb.putInt(nanos);
-                            break;
-                        case ServerConstants.SQLDTCODE_MPDATETIME:
-                            break;
-                    }
-                default:
-            }
-            break;
-        case ServerConstants.SQLTYPECODE_INTERVAL:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_INTERVAL :" + Arrays.toString(sqlarray));
-            len = tb.getShort();
-            dst = new byte[len];
-            System.arraycopy(sqlarray, 2, dst, 0, len);
-            Arrays.fill(sqlarray, (byte)0);
-            tb.clear();
-            if(dst[0] != '-'){
-                len++;
-                tb.put((byte)' ');
-            }
-            tb.put(dst, 0, dst.length);
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: sqlarray :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_INTEGER:                    //4
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_INTEGER :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_INTEGER_UNSIGNED:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_INTEGER_UNSIGNED :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_SMALLINT:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_SMALLINT :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_SMALLINT_UNSIGNED:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_SMALLINT_UNSIGNED :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_LARGEINT:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_LARGEINT :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_DECIMAL:
-        case ServerConstants.SQLTYPECODE_DECIMAL_UNSIGNED:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_DECIMAL :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_IEEE_REAL:                    //6
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_IEEE_REAL :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_IEEE_FLOAT:                   //7
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_IEEE_FLOAT :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_IEEE_DOUBLE:                  //8
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_IEEE_DOUBLE :" + Arrays.toString(sqlarray));
-            break;
-        case ServerConstants.SQLTYPECODE_NUMERIC:
-        case ServerConstants.SQLTYPECODE_NUMERIC_UNSIGNED:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: SQLTYPECODE_NUMERIC :" + Arrays.toString(sqlarray));
-            switch (len) {
-            case 2:
-                setShort = tb.getShort();
-                setLong = setShort;
-                if(setLong < 0){
-                    setLong = -1L * setLong;
-                    setSign = true;
-                    tb.clear();
-                    tb.put((byte) ((setLong) & 0xff));
-                    tb.put((byte) (((setLong >>> 8) | 0x80) & 0xff));
-                }
-                break;
-            case 4:
-                setInt = tb.getInt();
-                setLong = setInt;
-                if(setLong < 0){
-                    setLong = -1L * setLong;
-                    setSign = true;
-                    tb.clear();
-                    tb.put((byte) ((setLong) & 0xff));
-                    tb.put((byte) ((setLong >>> 8) & 0xff));
-                    tb.put((byte) ((setLong >>> 16) & 0xff));
-                    tb.put((byte) (((setLong >>> 24) | 0x80) & 0xff));
-                }
-                break;
-            case 8:
-                setLong = tb.getLong();
-                if(setLong < 0){
-                    setLong = -1L * setLong;
-                    setSign = true;
-                    tb.clear();
-                    tb.put((byte) ((setLong) & 0xff));
-                    tb.put((byte) ((setLong >>> 8) & 0xff));
-                    tb.put((byte) ((setLong >>> 16) & 0xff));
-                    tb.put((byte) ((setLong >>> 24) & 0xff));
-                    tb.put((byte) ((setLong >>> 32) & 0xff));
-                    tb.put((byte) ((setLong >>> 40) & 0xff));
-                    tb.put((byte) ((setLong >>> 48) & 0xff));
-                    tb.put((byte) (((setLong >>> 56) | 0x80) & 0xff));
-                }
-                break;
-            }
-            break;
-        case ServerConstants.SQLTYPECODE_DECIMAL_LARGE:
-        case ServerConstants.SQLTYPECODE_DECIMAL_LARGE_UNSIGNED:
-        case ServerConstants.SQLTYPECODE_BIT:
-        case ServerConstants.SQLTYPECODE_BITVAR:
-        case ServerConstants.SQLTYPECODE_BPINT_UNSIGNED:
-        default:
-            if(LOG.isDebugEnabled())
-                LOG.debug("formatSqlT4Output: default :" + Arrays.toString(sqlarray));
-            break;
-        }
-        System.arraycopy(sqlarray, offset, outValues, (int)curOutPos, len);
-        return outValues;
-    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlPrepare.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlPrepare.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlPrepare.java
index 6472a43..8654ce6 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlPrepare.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlPrepare.java
@@ -50,7 +50,7 @@ public class ServerApiSqlPrepare {
     private static final int odbc_SQLSvc_Prepare_SQLStillExecuting_exn_ = 4;
     private static final int odbc_SQLSvc_Prepare_SQLQueryCancelled_exn_ = 5;
     private static final int odbc_SQLSvc_Prepare_TransactionError_exn_ = 6;
-    
+
     private static  final Log LOG = LogFactory.getLog(ServerApiSqlPrepare.class);
     private int instance;
     private int serverThread;
@@ -75,20 +75,19 @@ public class ServerApiSqlPrepare {
     private String stmtExplainLabel;
     private int maxRowsetSize;
     private String txId;
-//-----------------------------------------------    
+//-----------------------------------------------
     private int returnCode;
     private SQLWarningOrErrorList errorList;
     private int sqlQueryType;
     private int stmtHandle;
     private int estimatedCost;
-//-----------for params -------------------------
     private ParameterMetaData pmd = null;
     private SQLMXParameterMetaData spmtd = null;
-//-----------for input params -------------------
-    private int inpNumberParams;
-    private Descriptor2List inpDescList;
-//-----------for output params ------------------    
-    private int outNumberParams;
+//-----------for parameters -------------------
+    private int paramCount;
+    private Descriptor2List paramDescList;
+//-----------for output -----------------------
+    private int columnCount;
     private Descriptor2List outDescList;
 //-----------for result set --------------------
     private ResultSetMetaData rsmd = null;
@@ -98,19 +97,19 @@ public class ServerApiSqlPrepare {
     private int        odbcCharset_;
     private int        sqlDataType_;
     private int        dataType_;
-    private short    sqlPrecision_;
-    private short    sqlDatetimeCode_;
+    private short      sqlPrecision_;
+    private short      sqlDatetimeCode_;
     private int        sqlOctetLength_;
     private int        isNullable_;
-    private String    name_;
+    private String     name_;
     private int        scale_;
     private int        precision_;
     private boolean    isSigned_;
     private boolean    isCurrency_;
     private boolean    isCaseSensitive_;
     private String     catalogName_;
-    private String    schemaName_;
-    private String    tableName_;
+    private String     schemaName_;
+    private String     tableName_;
     private int        fsDataType_;
     private int        intLeadPrec_;
     private int        paramMode_;
@@ -120,10 +119,10 @@ public class ServerApiSqlPrepare {
     private int        odbcPrecision_;
     private int        maxLen_;
 
-    private int     displaySize_;
-    private String  label_;
+    private int        displaySize_;
+    private String     label_;
 
-    ServerApiSqlPrepare(int instance, int serverThread) {  
+    ServerApiSqlPrepare(int instance, int serverThread) {
         this.instance = instance;
         this.serverThread = serverThread;
         serverWorkerName = ServerConstants.SERVER_WORKER_NAME + "_" + instance + "_" + serverThread;
@@ -146,39 +145,39 @@ public class ServerApiSqlPrepare {
         stmtExplainLabel = "";
         maxRowsetSize = 32000;
         String txId = "";
-    
+
         returnCode = ServerConstants.SQL_SUCCESS;
         errorList = null;
         sqlQueryType = 0;
         stmtHandle = 0;
         estimatedCost = 0;
-        inpNumberParams = 0;
-        inpDescList = null;
-        outNumberParams = 0;
+        paramCount = 0;
+        paramDescList = null;
+        columnCount = 0;
         outDescList = null;
-        
+
         pmd = null;
         spmtd = null;
         rsmd = null;
-        strsmd = null;;
+        strsmd = null;
     }
-    ClientData processApi(ClientData clientData) {  
+    ClientData processApi(ClientData clientData) {
         this.clientData = clientData;
         init();
-//        
+//
 // ==============process input ByteBuffer===========================
-// 
+//
         ByteBuffer bbHeader = clientData.bbHeader;
         ByteBuffer bbBody = clientData.bbBody;
         Header hdr = clientData.hdr;
 
         bbHeader.flip();
         bbBody.flip();
-        
+
         try {
 
             hdr.extractFromByteArray(bbHeader);
-            
+
             dialogueId =  bbBody.getInt();
             sqlAsyncEnable =  bbBody.getInt();
             queryTimeout =  bbBody.getInt();
@@ -218,52 +217,35 @@ public class ServerApiSqlPrepare {
                 throw new SQLException(serverWorkerName + ". Wrong dialogueId sent by the Client [sent/expected] : [" + dialogueId + "/" + clientData.getDialogueId() + "]");
             }
             boolean isResultSet = false;
-            
-            switch (sqlStmtType){
-                case ServerConstants.TYPE_SELECT:
-                case ServerConstants.TYPE_EXPLAIN:
-                    isResultSet = true;
-                    break;
-                case ServerConstants.TYPE_UPDATE:
-                case ServerConstants.TYPE_DELETE:
-                case ServerConstants.TYPE_INSERT:
-                case ServerConstants.TYPE_INSERT_PARAM:
-                case ServerConstants.TYPE_CREATE:
-                case ServerConstants.TYPE_GRANT:
-                case ServerConstants.TYPE_DROP:
-                case ServerConstants.TYPE_CALL:
-                case ServerConstants.TYPE_CONTROL:
-                default:
-            }
+
 //=====================Process ServerApiSqlPrepare===========================
             try {
 
                 trafConn = clientData.getTrafConnection();
-                trafStmt = trafConn.prepareTrafStatement(stmtLabel, sqlString, isResultSet);
+                trafStmt = trafConn.prepareTrafStatement(stmtLabel, sqlString, sqlStmtType);
+                isResultSet = trafStmt.getIsResultSet();
+                stmtHandle = trafStmt.getStmtHandle();
                 pstmt = (PreparedStatement)trafStmt.getStatement();
-                
+
                 rsmd = pstmt.getMetaData();
                 pmd = pstmt.getParameterMetaData();
-                
-//-------------------------------------------------------------
+
                 if(isResultSet)
-                    outNumberParams = rsmd.getColumnCount();
-                LOG.debug(serverWorkerName + ". outNumberParams :" + outNumberParams);
-//-------------------------------------------------------------                
+                    columnCount = rsmd.getColumnCount();
                 if(pmd != null)
-                    inpNumberParams = pmd.getParameterCount();
-                LOG.debug(serverWorkerName + ". inpNumberParams :" + inpNumberParams);
-                
+                    paramCount = pmd.getParameterCount();
+
                 if(LOG.isDebugEnabled()){
-                    LOG.debug(serverWorkerName + ".outNumberParams :" + outNumberParams);
-                    LOG.debug(serverWorkerName + ".inpNumberParams :" + inpNumberParams);
+                    LOG.debug(serverWorkerName + ".stmtHandle :" + stmtHandle);
+                    LOG.debug(serverWorkerName + ".columnCount :" + columnCount);
+                    LOG.debug(serverWorkerName + ".paramCount :" + paramCount);
                 }
-                if (outNumberParams > 0){
+                if (columnCount > 0){
 //                  strsmd = ((TResultSetMetaData)rsmd).getSqlResultSetMetaData();
                     strsmd = (SQLMXResultSetMetaData)rsmd;
-                    outDescList = new Descriptor2List(outNumberParams, false);
-                    
-                    for (int column = 1; column <= outNumberParams; column++){
+                    outDescList = new Descriptor2List(columnCount, false);
+
+                    for (int column = 1; column <= columnCount; column++){
                         sqlCharset_ = strsmd.getSqlCharset(column);
                         odbcCharset_ = strsmd.getOdbcCharset(column);
                         sqlDataType_ = strsmd.getSqlDataType(column);
@@ -286,13 +268,13 @@ public class ServerApiSqlPrepare {
                         paramMode_ = strsmd.getMode(column);
                         paramIndex_ = strsmd.getIndex(column);
                         paramPos_ = strsmd.getPos(column);
-                        
+
                         odbcPrecision_ = strsmd.getOdbcPrecision(column);
                         maxLen_ = strsmd.getMaxLen(column);
-                        
+
                         displaySize_ = strsmd.getDisplaySize(column);
                         label_ = strsmd.getLabel(column);
- 
+
                         Descriptor2 outDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
                             sqlOctetLength_,isNullable_,name_,scale_,precision_,isSigned_,
                             isCurrency_,isCaseSensitive_,catalogName_,schemaName_,tableName_,
@@ -301,9 +283,9 @@ public class ServerApiSqlPrepare {
                         outDescList.addDescriptor(column,outDesc);
                     }
                     if(LOG.isDebugEnabled()){
-                        for (int column = 1; column <= outNumberParams; column++){
+                        for (int column = 1; column <= columnCount; column++){
                             Descriptor2 dsc = outDescList.getDescriptors2()[column-1];
-                            LOG.debug(serverWorkerName + ". [" + column + "] Output descriptor -------------" );
+                            LOG.debug(serverWorkerName + ". [" + column + "] Column descriptor -------------" );
                             LOG.debug(serverWorkerName + ". oldFormat " + column + " :" + dsc.getOldFormat());
                             LOG.debug(serverWorkerName + ". noNullValue " + column + " :" + dsc.getNoNullValue());
                             LOG.debug(serverWorkerName + ". nullValue " + column + " :" + dsc.getNullValue());
@@ -323,21 +305,19 @@ public class ServerApiSqlPrepare {
                             LOG.debug(serverWorkerName + ". tableName " + column + " :" + dsc.getTableName());
                             LOG.debug(serverWorkerName + ". schemaName " + column + " :" + dsc.getSchemaName());
                             LOG.debug(serverWorkerName + ". headingName " + column + " :" + dsc.getHeadingName());
-                            LOG.debug(serverWorkerName + ". intLeadPrec " + column + " :" + dsc.getParamMode());
-                            LOG.debug(serverWorkerName + ". paramMode " + column + " :" + dsc.getColHeadingNm());
-                            LOG.debug(serverWorkerName + ". memAlignOffset " + column + " :" + dsc.getMemAlignOffset());
-                            LOG.debug(serverWorkerName + ". allocSize " + column + " :" + dsc.getAllocSize());
-                            LOG.debug(serverWorkerName + ". varLayout " + column + " :" + dsc.getVarLayout());
-                            LOG.debug(serverWorkerName + ". Output descriptor End-------------");
+                            LOG.debug(serverWorkerName + ". intLeadPrec " + column + " :" + dsc.getIntLeadPrec());
+                            LOG.debug(serverWorkerName + ". paramMode " + column + " :" + dsc.getParamMode());
+                            LOG.debug(serverWorkerName + ". varLength " + column + " :" + dsc.getVarLength());
+                            LOG.debug(serverWorkerName + ". Column descriptor End-------------");
                         }
                     }
                 }
-                if (inpNumberParams > 0){
-//                    spmtd = ((TParameterMetaData)pmd).getSqlParameterMetaData();
+                if (paramCount > 0){
+//                  spmtd = ((TParameterMetaData)pmd).getSqlParameterMetaData();
                     spmtd = (SQLMXParameterMetaData)pmd;
-                    inpDescList = new Descriptor2List(inpNumberParams, false);
-                    
-                    for(int param = 1; param <= inpNumberParams; param++){
+                    paramDescList = new Descriptor2List(paramCount, false);
+
+                    for(int param = 1; param <= paramCount; param++){
                         sqlCharset_ = spmtd.getSqlCharset(param);
                         odbcCharset_ = spmtd.getOdbcCharset(param);
                         sqlDataType_ = spmtd.getSqlDataType(param);
@@ -364,18 +344,18 @@ public class ServerApiSqlPrepare {
                         maxLen_ = spmtd.getMaxLen(param);
                         displaySize_ = spmtd.getDisplaySize(param);
                         label_ = spmtd.getLabel(param);
-                        
-                        Descriptor2 inpDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
+
+                        Descriptor2 paramDesc = new Descriptor2(sqlCharset_,odbcCharset_,sqlDataType_,dataType_,sqlPrecision_,sqlDatetimeCode_,
                             sqlOctetLength_,isNullable_,name_,scale_,precision_,isSigned_,
                             isCurrency_,isCaseSensitive_,catalogName_,schemaName_,tableName_,
                             fsDataType_,intLeadPrec_,paramMode_,paramIndex_,paramPos_,odbcPrecision_,
                             maxLen_,displaySize_,label_,false);
-                        inpDescList.addDescriptor(param,inpDesc);
+                        paramDescList.addDescriptor(param,paramDesc);
                     }
                     if(LOG.isDebugEnabled()){
-                        for (int param = 1; param <= inpNumberParams; param++){
-                            Descriptor2 dsc = inpDescList.getDescriptors2()[param-1];
-                            LOG.debug(serverWorkerName + ". [" + param + "] Input descriptor -------------" );
+                        for (int param = 1; param <= paramCount; param++){
+                            Descriptor2 dsc = paramDescList.getDescriptors2()[param-1];
+                            LOG.debug(serverWorkerName + ". [" + param + "] Parameter descriptor -------------" );
                             LOG.debug(serverWorkerName + ". oldFormat " + param + " :" + dsc.getOldFormat());
                             LOG.debug(serverWorkerName + ". noNullValue " + param + " :" + dsc.getNoNullValue());
                             LOG.debug(serverWorkerName + ". nullValue " + param + " :" + dsc.getNullValue());
@@ -395,31 +375,27 @@ public class ServerApiSqlPrepare {
                             LOG.debug(serverWorkerName + ". tableName " + param + " :" + dsc.getTableName());
                             LOG.debug(serverWorkerName + ". schemaName " + param + " :" + dsc.getSchemaName());
                             LOG.debug(serverWorkerName + ". headingName " + param + " :" + dsc.getHeadingName());
-                            LOG.debug(serverWorkerName + ". intLeadPrec " + param + " :" + dsc.getParamMode());
-                            LOG.debug(serverWorkerName + ". paramMode " + param + " :" + dsc.getColHeadingNm());
-                            LOG.debug(serverWorkerName + ". memAlignOffset " + param + " :" + dsc.getMemAlignOffset());
-                            LOG.debug(serverWorkerName + ". allocSize " + param + " :" + dsc.getAllocSize());
-                            LOG.debug(serverWorkerName + ". varLayout " + param + " :" + dsc.getVarLayout());
-                            LOG.debug(serverWorkerName + ". Input descriptor End -------------" );
+                            LOG.debug(serverWorkerName + ". intLeadPrec " + param + " :" + dsc.getIntLeadPrec());
+                            LOG.debug(serverWorkerName + ". paramMode " + param + " :" + dsc.getParamMode());
+                            LOG.debug(serverWorkerName + ". varLength " + param + " :" + dsc.getVarLength());
+                            LOG.debug(serverWorkerName + ". Parameter descriptor End -------------" );
                         }
                     }
                 }
             } catch (SQLException ex){
                 LOG.error(serverWorkerName + ". Prepare.SQLException " + ex);
-                errorList = new SQLWarningOrErrorList(ex); 
+                errorList = new SQLWarningOrErrorList(ex);
                 returnCode = errorList.getReturnCode();
             }
-            sqlQueryType = sqlStmtType;
-            
+            sqlQueryType = SqlUtils.getSqlStmtType(sqlStmtType);
+
             if (returnCode == ServerConstants.SQL_SUCCESS || returnCode == ServerConstants.SQL_SUCCESS_WITH_INFO) {
-                trafStmt.setInpNumberParams(inpNumberParams);
-                if (inpNumberParams > 0){
-                    trafStmt.setInpParamLength(inpDescList.getParamLength());
-                    trafStmt.setInpDescList(inpDescList);
+                trafStmt.setParamCount(paramCount);
+                if (paramCount > 0){
+                    trafStmt.setParamLength(paramDescList.getVarLength());
+                    trafStmt.setParamDescList(paramDescList);
                 }
-                trafStmt.setOutNumberParams(outNumberParams);
-                if (outNumberParams > 0){
-                    trafStmt.setOutParamLength(outDescList.getParamLength());
+                if (columnCount > 0){
                     trafStmt.setOutDescList(outDescList);
                 }
             }
@@ -430,7 +406,7 @@ public class ServerApiSqlPrepare {
             bbBody.clear();
 //
 // check if ByteBuffer is big enough for output
-//      
+//
             int dataLength = ServerConstants.INT_FIELD_SIZE;        //returnCode
             if (returnCode == ServerConstants.SQL_SUCCESS || returnCode == ServerConstants.SQL_SUCCESS_WITH_INFO) {
                 if (returnCode == ServerConstants.SQL_SUCCESS_WITH_INFO) {
@@ -443,17 +419,16 @@ public class ServerApiSqlPrepare {
                 dataLength += ServerConstants.INT_FIELD_SIZE;    //stmtHandle
                 dataLength += ServerConstants.INT_FIELD_SIZE;    //estimatedCost
 
-                 if (inpNumberParams > 0)
-                    dataLength += inpDescList.lengthOfData();
+                 if (paramCount > 0) // input parameter
+                    dataLength += paramDescList.lengthOfData();
                  else
                     dataLength += ServerConstants.INT_FIELD_SIZE;
-                 
-                if (outNumberParams > 0)
-                    dataLength += outDescList.lengthOfData();
-                else
+
+                 if (paramCount > 0) // output parameter
+                    dataLength += paramDescList.lengthOfData();
+                 else
                     dataLength += ServerConstants.INT_FIELD_SIZE;
-             }
-            else {
+             } else {
                 if (errorList != null)
                     dataLength += errorList.lengthOfData();
                 else
@@ -477,24 +452,26 @@ public class ServerApiSqlPrepare {
                 bbBody.putInt(stmtHandle);
                 bbBody.putInt(estimatedCost);
 
-                if (inpNumberParams > 0)
-                    inpDescList.insertIntoByteBuffer(bbBody);
+                if(LOG.isDebugEnabled())
+                    LOG.debug(serverWorkerName + ". sqlQueryType :" + sqlQueryType + ", stmtHandle :" + stmtHandle + ", estimatedCost :" + estimatedCost);
+
+                if (paramCount > 0) //input
+                    paramDescList.insertIntoByteBuffer(bbBody);
                 else
                     bbBody.putInt(0);
 
-                if (outNumberParams > 0)
-                    outDescList.insertIntoByteBuffer(bbBody);
+                if (paramCount > 0) //output
+                    paramDescList.insertIntoByteBuffer(bbBody);
                 else
                     bbBody.putInt(0);
-            }
-            else {
+            } else {
                 if (errorList != null)
                     errorList.insertIntoByteBuffer(bbBody);
                 else
                     bbBody.putInt(0);
             }
             bbBody.flip();
-//=========================Update header================================ 
+//=========================Update header================================
             hdr.setTotalLength(bbBody.limit());
             hdr.insertIntoByteBuffer(bbHeader);
             bbHeader.flip();
@@ -502,7 +479,7 @@ public class ServerApiSqlPrepare {
             clientData.setByteBufferArray(bbHeader, bbBody);
             clientData.setHdr(hdr);
             clientData.setRequest(ServerConstants.REQUST_WRITE_READ);
-            
+
         } catch (UnsupportedEncodingException ue){
             LOG.error(serverWorkerName + ". Prepare.UnsupportedEncodingException :" + ue);
             clientData.setRequestAndDisconnect();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlSetConnectAttr.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlSetConnectAttr.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlSetConnectAttr.java
index 6da2db6..4f54127 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlSetConnectAttr.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiSqlSetConnectAttr.java
@@ -44,13 +44,13 @@ public class ServerApiSqlSetConnectAttr {
     private static final int odbc_SQLSvc_SetConnectionOption_InvalidConnection_exn_ = 2;
     private static final int odbc_SQLSvc_SetConnectionOption_SQLError_exn_ = 3;
     private static final int odbc_SQLSvc_SetConnectionOption_SQLInvalidHandle_exn_ = 4;
-    
+
     private static  final Log LOG = LogFactory.getLog(ServerApiSqlSetConnectAttr.class);
     private int instance;
     private int serverThread;
     private String serverWorkerName;
     private ClientData clientData;
-//    
+//
     private SetConnectionOption setConnectionOption;
     private ServerException serverException;
     private ErrorDescList errorDescList;
@@ -59,8 +59,8 @@ public class ServerApiSqlSetConnectAttr {
     private TrafConnection trafConnection;
     private int attr;
     private int option;
-    
-    ServerApiSqlSetConnectAttr(int instance, int serverThread) {  
+
+    ServerApiSqlSetConnectAttr(int instance, int serverThread) {
         this.instance = instance;
         this.serverThread = serverThread;
         serverWorkerName = ServerConstants.SERVER_WORKER_NAME + "_" + instance + "_" + serverThread;
@@ -75,7 +75,7 @@ public class ServerApiSqlSetConnectAttr {
         serverException = null;
         errorDescList = null;
     }
-    ClientData processApi(ClientData clientData) {  
+    ClientData processApi(ClientData clientData) {
         this.clientData = clientData;
         init();
 // ==============process input ByteBuffer===========================
@@ -87,11 +87,11 @@ public class ServerApiSqlSetConnectAttr {
 
         bbHeader.flip();
         bbBody.flip();
-        
+
         try {
             hdr.extractFromByteArray(bbHeader);
             setConnectionOption.extractFromByteBuffer(bbBody);
-    
+
             if (setConnectionOption.getDialogueId() < 1 ) {
                 throw new SQLException(serverWorkerName + ". Wrong dialogueId :" + setConnectionOption.getDialogueId());
             }
@@ -106,7 +106,7 @@ public class ServerApiSqlSetConnectAttr {
             trafConnection = clientData.getTrafConnection();
             attr = setConnectionOption.getConnectionOption();
             option = setConnectionOption.getOptionValueNum();
-            
+
             switch(attr){
             case ServerConstants.SQL_ATTR_ROWSET_RECOVERY:
                 if(LOG.isDebugEnabled())
@@ -129,22 +129,7 @@ public class ServerApiSqlSetConnectAttr {
                 if(LOG.isDebugEnabled())
                     LOG.debug(serverWorkerName + ". Unknown Connection Attr: [" + attr + "/" + option + "]" );
             }
-            errorDescList = new ErrorDescList(1);
-            errorDescList.getBuffer()[0].setRowId(1);
-            errorDescList.getBuffer()[0].setErrorDiagnosticId(2);
-            errorDescList.getBuffer()[0].setSqlcode(3);
-            errorDescList.getBuffer()[0].setSqlstate("state");
-            errorDescList.getBuffer()[0].setErrorText("Text");
-            errorDescList.getBuffer()[0].setOperationAbortId(4);
-            errorDescList.getBuffer()[0].setErrorCodeType(5);
-            errorDescList.getBuffer()[0].setParam1("A");
-            errorDescList.getBuffer()[0].setParam2("B");
-            errorDescList.getBuffer()[0].setParam3("C");
-            errorDescList.getBuffer()[0].setParam4("D");
-            errorDescList.getBuffer()[0].setParam5("E");
-            errorDescList.getBuffer()[0].setParam6("F");
-            errorDescList.getBuffer()[0].setParam7("G");
-            
+            errorDescList = new ErrorDescList();
             serverException.setServerException (exception, exception_detail, errorDescList);
 //
 //===================calculate length of output ByteBuffer========================
@@ -155,7 +140,7 @@ public class ServerApiSqlSetConnectAttr {
             bbBody.clear();
 //
 // check if ByteBuffer is big enough for serverException
-//      
+//
             int dataLength = serverException.lengthOfData();
             int availableBuffer = bbBody.capacity() - bbBody.position();
              if(LOG.isDebugEnabled())
@@ -166,7 +151,7 @@ public class ServerApiSqlSetConnectAttr {
             serverException.insertIntoByteBuffer(bbBody);
 
             bbBody.flip();
-//=========================Update header================================ 
+//=========================Update header================================
             hdr.setTotalLength(bbBody.limit());
             hdr.insertIntoByteBuffer(bbHeader);
             bbHeader.flip();
@@ -174,7 +159,7 @@ public class ServerApiSqlSetConnectAttr {
             clientData.setByteBufferArray(bbHeader, bbBody);
             clientData.setHdr(hdr);
             clientData.setRequest(ServerConstants.REQUST_WRITE_READ);
-            
+
         } catch (SQLException se){
             LOG.error(serverWorkerName + ". SetConnectAttr.SQLException :" + se);
             clientData.setRequestAndDisconnect();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafConnection.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafConnection.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafConnection.java
index 35129ef..c2fba36 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafConnection.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafConnection.java
@@ -30,12 +30,12 @@ import java.nio.channels.*;
 import java.nio.channels.spi.*;
 import java.util.*;
 import java.util.concurrent.*;
-import java.sql.*;
 
 import org.apache.hadoop.conf.Configuration;
 
 import org.trafodion.dcs.Constants;
 import org.trafodion.dcs.util.*;
+import org.trafodion.dcs.servermt.ServerConstants;
 import org.trafodion.dcs.servermt.serverDriverInputOutput.*;
 import org.trafodion.dcs.servermt.serverHandler.*;
 import org.apache.commons.logging.Log;
@@ -82,6 +82,11 @@ public class TrafConnection {
 
     private VersionList clientVersionList = null;
 
+    private short clientComponentId = 0;
+    private short clientMajorVersion = 0;
+    private short clientMinorVersion = 0;
+    private int clientBuildId = 0;
+
     private int dialogueId = 0;
     private long contextOptions1 = 0L;
     private long contextOptions2 = 0L;
@@ -139,6 +144,22 @@ public class TrafConnection {
         contextOptions2 = cc.getContextOptions2();
         sessionName = cc.getSessionName();
         clientUserName = cc.getClientUserName();
+
+        Version[] cvl = clientVersionList.getList();
+        for (int i = 0; i < cvl.length; i ++ ){
+            Version cv = cvl[i];
+            if (i == 0){
+                clientComponentId = cv.getComponentId();
+                clientMajorVersion = cv.getMajorVersion();
+                clientMinorVersion = cv.getMinorVersion();
+                clientBuildId = cv.getBuildId();
+            }
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(serverWorkerName + ". version index :" + 0);
+                cv.debug();
+            }
+        }
+
         /*--------------------------------------------------------------------
          T2 Driver properties
          catalog
@@ -278,69 +299,55 @@ public class TrafConnection {
 
     public void closeTConnection() {
         TrafStatement tstmt;
-        Iterator<String> keySetIterator = statements.keySet().iterator();
-        if (LOG.isDebugEnabled())
-            LOG.debug(serverWorkerName + ". closeTConnection");
-        while (keySetIterator.hasNext()) {
-            String key = keySetIterator.next();
-            tstmt = statements.get(key);
-            tstmt.closeTStatement();
-        }
-        statements.clear();
         try {
-            if (isClosed == false) {
-                isClosed = true;
-                conn.close();
+            Iterator<String> keySetIterator = statements.keySet().iterator();
+            if (LOG.isDebugEnabled())
+                LOG.debug(serverWorkerName + ". closeTConnection");
+            while (keySetIterator.hasNext()) {
+                String key = keySetIterator.next();
+                tstmt = statements.get(key);
+                tstmt.closeTStatement();
             }
+            statements.clear();
+                if (isClosed == false) {
+                    isClosed = true;
+                    conn.close();
+                }
         } catch (SQLException sql) {
         }
         reset();
     }
 
-    public TrafStatement createTrafStatement(String stmtLabel,
-            boolean isResultSet) throws SQLException {
+    public TrafStatement createTrafStatement(String stmtLabel, int sqlStmtType, int stmtHandle) throws SQLException {
         TrafStatement trafStatement = null;
 
         if (statements.containsKey(stmtLabel) == false) {
             if (LOG.isDebugEnabled())
                 LOG.debug(serverWorkerName
-                        + ". createTrafStatement.containsKey [" + stmtLabel
-                        + "] is false ");
-            trafStatement = new TrafStatement(serverWorkerName, stmtLabel,
-                    conn, null);
-            trafStatement.setIsResultSet(isResultSet);
+                        + ". createTrafStatement.containsKey [" + stmtLabel + "] is false ");
+            trafStatement = new TrafStatement(serverWorkerName, stmtLabel, conn, null, sqlStmtType);
             statements.put(stmtLabel, trafStatement);
         } else {
-            LOG.debug(serverWorkerName + ". createTrafStatement.containsKey ["
-                    + stmtLabel + "] is found ");
-            trafStatement = getTrafStatement(stmtLabel);
-            trafStatement.setStatement(conn, null);
-            trafStatement.setIsResultSet(isResultSet);
+            LOG.debug(serverWorkerName + ". createTrafStatement.containsKey [" + stmtLabel + "] is found ");
+            trafStatement = getTrafStatement(stmtLabel, stmtHandle);
+            trafStatement.setStatement(conn, null, sqlStmtType);
         }
         return trafStatement;
     }
 
-    public TrafStatement prepareTrafStatement(String stmtLabel,
-            String sqlString, boolean isResultSet) throws SQLException {
+    public TrafStatement prepareTrafStatement(String stmtLabel, String sqlString, int sqlStmtType) throws SQLException {
         TrafStatement trafStatement = null;
 
         if (statements.containsKey(stmtLabel) == false) {
             if (LOG.isDebugEnabled())
-                LOG.debug(serverWorkerName
-                        + ". prepareTrafStatement.containsKey [" + stmtLabel
-                        + "] is false ");
-            trafStatement = new TrafStatement(serverWorkerName, stmtLabel,
-                    conn, sqlString);
-            trafStatement.setIsResultSet(isResultSet);
+                LOG.debug(serverWorkerName + ". prepareTrafStatement.containsKey [" + stmtLabel + "] is false ");
+            trafStatement = new TrafStatement(serverWorkerName, stmtLabel, conn, sqlString, sqlStmtType);
             statements.put(stmtLabel, trafStatement);
         } else {
             if (LOG.isDebugEnabled())
-                LOG.debug(serverWorkerName
-                        + ". prepareTrafStatement.containsKey [" + stmtLabel
-                        + "] is found ");
-            trafStatement = getTrafStatement(stmtLabel);
-            trafStatement.setStatement(conn, sqlString);
-            trafStatement.setIsResultSet(isResultSet);
+                LOG.debug(serverWorkerName + ". prepareTrafStatement.containsKey [" + stmtLabel + "] is found ");
+            trafStatement = getTrafStatement(stmtLabel, 0);
+            trafStatement.setStatement(conn, sqlString, sqlStmtType);
         }
         return trafStatement;
     }
@@ -351,27 +358,37 @@ public class TrafConnection {
 
         if (statements.containsKey(stmtLabel) == false) {
             if (LOG.isDebugEnabled())
-                LOG.debug(serverWorkerName
-                        + ". closeTrafStatement.containsKey [" + stmtLabel
-                        + "] is false ");
+                LOG.debug(serverWorkerName + ". closeTrafStatement.containsKey [" + stmtLabel + "] is false ");
         } else {
             if (LOG.isDebugEnabled())
-                LOG.debug(serverWorkerName
-                        + ". createTrafStatement.containsKey [" + stmtLabel
-                        + "] is found ");
-            trafStatement = getTrafStatement(stmtLabel);
+                LOG.debug(serverWorkerName + ". closeTrafStatement.containsKey [" + stmtLabel + "] is found ");
+            trafStatement = getTrafStatement(stmtLabel, 0);
             trafStatement.closeTStatement();
         }
         return trafStatement;
     }
 
-    public TrafStatement getTrafStatement(String stmtLabel) throws SQLException {
+    public TrafStatement getTrafStatement(String stmtLabel, int stmtHandle) throws SQLException {
         TrafStatement trafStatement = null;
-        trafStatement = statements.get(stmtLabel);
-        if (trafStatement == null)
-            throw new SQLException("getTrafStatement [" + stmtLabel
-                    + "] returns null");
-        return trafStatement;
+        if (stmtLabel != null && stmtLabel.isEmpty() == false){
+            trafStatement = statements.get(stmtLabel);
+            if (trafStatement == null)
+                throw new SQLException("getTrafStatement stmtLabel : [" + stmtLabel + "] returns null");
+            return trafStatement;
+        } else if (stmtHandle == 0)
+            throw new SQLException("getTrafStatement stmtHandle is 0 [" + stmtHandle + "]");
+        else {
+            TrafStatement  tstmt;
+            String key;
+            Iterator<String> keySetIterator = statements.keySet().iterator();
+            while (keySetIterator.hasNext()) {
+                key = keySetIterator.next();
+                tstmt = statements.get(key);
+                if (tstmt.getStmtHandle() == stmtHandle);
+                    return tstmt;
+            }
+            throw new SQLException("getTrafStatement stmtHandle [" + stmtHandle + "] returns null");
+       }
     }
 
     public void setDatasource(String datasource) {
@@ -623,6 +640,22 @@ public class TrafConnection {
         return clientUserName;
     }
 
+    public short getClientComponentId(){
+        return clientComponentId;
+    }
+
+    public short getClientMajorVersion(){
+        return clientMajorVersion;
+    }
+
+    public short getClientMinorVersion(){
+        return clientMinorVersion;
+    }
+
+    public int getClientBuildId(){
+        return clientBuildId;
+    }
+
     public Connection getConnection() {
         return conn;
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/661f4ad8/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafResultSet.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafResultSet.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafResultSet.java
new file mode 100644
index 0000000..648df0d
--- /dev/null
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverSql/TrafResultSet.java
@@ -0,0 +1,154 @@
+/**
+* @@@ 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.dcs.servermt.serverSql;
+
+import java.sql.*;
+import java.net.*;
+import java.io.*;
+import java.nio.*;
+import java.nio.channels.*;
+import java.nio.channels.spi.*;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.trafodion.dcs.Constants;
+import org.trafodion.dcs.servermt.ServerConstants;
+import org.trafodion.dcs.util.*;
+import org.trafodion.dcs.servermt.serverDriverInputOutput.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TrafResultSet {
+    private static  final Log LOG = LogFactory.getLog(TrafResultSet.class);
+
+    /* -----------------output for resultset
+        int stmt_handle                    (int)
+        String stmtLabels[resultSetIndex]  (String)
+        long stmt_label_charset            (int)
+        ----- Descriptor2List------------------------
+        outputDescLength                   (int)
+        if (outputDescLength > 0){
+            outputParamsLength             (int)
+            outputNumberParams             (int)
+
+            for (int j = 0; j < outputNumberParams; j++) {
+                Descriptor2(buf, ic);      (Descriptor2)
+            }
+        }
+        proxySyntax[resultSetIndex] = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
+    ------------------------ end of resultset
+    */
+    private boolean isClosed;
+    private ResultSet rs;
+
+    private int stmtHandle;
+    private String stmtLabel;
+    private long stmtLabelCharset;
+    private Descriptor2List columnDescList;
+    private String proxySyntax;
+
+    public TrafResultSet(ResultSet rs, int stmtHandle, String stmtLabel, long stmtLabelCharset, Descriptor2List columnDescList, String proxySyntax){
+        if(LOG.isDebugEnabled())
+             LOG.debug("TrafResultSet constructor");
+        init();
+        this.rs = rs;
+        this.stmtHandle = stmtHandle;
+        this.stmtLabel = stmtLabel;
+        this.stmtLabelCharset = stmtLabelCharset;
+        this.columnDescList = columnDescList;
+        this.proxySyntax = proxySyntax;
+    }
+    void init(){
+        reset();
+    }
+    void reset(){
+        isClosed = false;
+        rs = null;
+        stmtHandle = 0;
+        stmtLabel = "";
+        stmtLabelCharset = 0;
+        columnDescList = null;
+        proxySyntax = null;
+    }
+    public void insertIntoByteBuffer(ByteBuffer bbBuf) throws UnsupportedEncodingException {
+        bbBuf.putInt(stmtHandle);
+        ByteBufferUtils.insertString(stmtLabel,bbBuf);
+        bbBuf.putInt((int)stmtLabelCharset);
+        columnDescList.insertIntoByteBuffer(bbBuf);
+        ByteBufferUtils.insertString(proxySyntax,bbBuf);
+    }
+    public int lengthOfData() {
+        int length = ServerConstants.INT_FIELD_SIZE; //stmtHandle
+        length += ByteBufferUtils.lengthOfString(stmtLabel);
+        length += ServerConstants.INT_FIELD_SIZE;  //stmtLabelCharset
+        length += columnDescList.lengthOfData();
+        length += ByteBufferUtils.lengthOfString(proxySyntax);
+        return length;
+    }
+    public void closeTResultSet(){
+        try {
+           if (rs != null && isClosed == false){
+               rs.close();
+               isClosed = true;
+               rs = null;
+           }
+         } catch (SQLException sql){}
+    }
+    public boolean isClosed(){
+        return isClosed;
+    }
+    public ResultSet getResultSet(){
+        return rs;
+    }
+    public String getStmtLabel(){
+        return stmtLabel;
+    }
+    public long getStmtLabelCharset(){
+        return stmtLabelCharset;
+    }
+    public Descriptor2List getColumnDescList(){
+        return columnDescList;
+    }
+    public String getProxySyntax(){
+        return proxySyntax;
+    }
+    public void setResultSet(ResultSet rs){
+        this.rs = rs;
+    }
+    public void setStmtLabel(String stmtLabel){
+        this.stmtLabel = stmtLabel;
+    }
+    public void setStmtLabelCharset(long stmtLabelCharset){
+        this.stmtLabelCharset = stmtLabelCharset;
+    }
+    public void setColumnDescList(Descriptor2List columnDescList){
+        this.columnDescList = columnDescList;
+    }
+    public void setProxySyntax(String proxySyntax){
+        this.proxySyntax = proxySyntax;
+    }
+}


[5/6] incubator-trafodion git commit: Removed commented code

Posted by su...@apache.org.
Removed commented code


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/dd15115e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/dd15115e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/dd15115e

Branch: refs/heads/master
Commit: dd15115e81b16afea15e0d342c7ebf4e2d125bd4
Parents: 661f4ad
Author: Arvind Narain <ar...@dev02.trafodion.org>
Authored: Fri Oct 9 05:06:10 2015 +0000
Committer: Arvind Narain <ar...@dev02.trafodion.org>
Committed: Fri Oct 9 05:06:10 2015 +0000

----------------------------------------------------------------------
 .../serverHandler/ServerApiGetCatalogs.java     | 81 --------------------
 1 file changed, 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dd15115e/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
index 86a5515..82b9bbc 100644
--- a/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
+++ b/dcs/src/main/java/org/trafodion/dcs/servermt/serverHandler/ServerApiGetCatalogs.java
@@ -445,13 +445,6 @@ public class ServerApiGetCatalogs {
             if (outCount > 0){
                 trafStmt.addTResultSet(new TrafResultSet(rs, 0, stmtLabel, 0, outDescList,""));
             }
-/*
-            trafStmt.setoutCount(outCount);
-            if (outCount > 0){
-                trafStmt.setColumnLength(outDescList.getVarLength());
-                trafStmt.setoutDescList(outDescList);
-            }
-*/
 //
 //===================calculate length of output ByteBuffer========================
 //
@@ -460,16 +453,6 @@ public class ServerApiGetCatalogs {
 //
 // check if ByteBuffer is big enough for output
 //
-//===================== build output ==============================================
-//
-/*          odbc_SQLSvc_GetSQLCatalogs_exc_ m_p1;
-            String m_p2; stmtLabel
-            SQLItemDescList_def m_p3;
-            ERROR_DESC_LIST_def m_p4;
-            String proxySyntax = "";
-*/
-// check if ByteBuffer is big enough for output
-//
             int dataLength = serverException.lengthOfData();
             dataLength += ByteBufferUtils.lengthOfString(stmtLabel); //stmtLabel
             if (outDescList != null)
@@ -522,68 +505,4 @@ public class ServerApiGetCatalogs {
         return clientData;
     }
 }
-/*
-//
-// length of odbc_SQLSvc_GetSQLCatalogs_exc_ *exception_
-//
-    wlength += sizeof(exception_->exception_nr);
-    wlength += sizeof(exception_->exception_detail);
-
-    switch(exception_->exception_nr)
-    {
-        case odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_:
-           wlength += sizeof(exceptionLength);
-           if (exception_->u.ParamError.ParamDesc != NULL)
-           {
-              exceptionLength = strlen(exception_->u.ParamError.ParamDesc) + 1;
-              wlength += exceptionLength;
-           }
-           break;
-
-        case odbc_SQLSvc_GetSQLCatalogs_SQLError_exn_:
-            ERROR_DESC_LIST_length( (ERROR_DESC_LIST_def *)&exception_->u.SQLError.errorList, wlength);
-            break;
-
-        case odbc_SQLSvc_GetSQLCatalogs_InvalidConnection_exn_:
-        case odbc_SQLSvc_GetSQLCatalogs_SQLInvalidHandle_exn_:
-            break;
-        default:
-            break;
-    }
-
-//
-// length of IDL_char *catStmtLabel
-//
-    wlength += sizeof(catStmtLabelLength);
-    if (catStmtLabel != NULL)
-    {
-        catStmtLabelLength = strlen(catStmtLabel)+1;
-        wlength += catStmtLabelLength;
-    }
-
-//
-// length of SQLItemDescList_def *outputDesc
-//
-    SQLITEMDESC_LIST_length( outputDesc, wlength);
-
-//
-// length of ERROR_DESC_LIST_def *sqlWarning
-//
-//
-    ERROR_DESC_LIST_LENGTH2(sqlWarning)
-
-//
-//
-//
-
-  wlength += sizeof (proxySyntaxStringLen);
 
-  if((pSrvrStmt != NULL) && (pSrvrStmt->SpjProxySyntaxString != NULL))
-    proxySyntaxStringLen = strlen(pSrvrStmt->SpjProxySyntaxString);
-  else
-    proxySyntaxStringLen = 0;
-
-  if(proxySyntaxStringLen > 0)
-    wlength += proxySyntaxStringLen + 1; // null terminated string
-
- */