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:58 UTC

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

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();