Lob support in T2 driver with streaming capability
diff --git a/core/conn/jdbc_type2/Makefile b/core/conn/jdbc_type2/Makefile
index 00e8f17..c4b40b5 100644
--- a/core/conn/jdbc_type2/Makefile
+++ b/core/conn/jdbc_type2/Makefile
@@ -46,6 +46,10 @@
        $(OUTDIR)/SQLMXPreparedStatement.o \
        $(OUTDIR)/SQLMXResultSet.o \
        $(OUTDIR)/SQLMXStatement.o \
+       $(OUTDIR)/SQLMXClobReader.o \
+       $(OUTDIR)/SQLMXClobWriter.o \
+       $(OUTDIR)/SQLMXLobInputStream.o \
+       $(OUTDIR)/SQLMXLobOutputStream.o \
        $(OUTDIR)/SrvrJdbcConnect.o \
        $(OUTDIR)/CDesc.o \
        $(OUTDIR)/SrvrCommon.o \
@@ -65,6 +69,10 @@
 		org.apache.trafodion.jdbc.t2.T2Driver \
 		org.apache.trafodion.jdbc.t2.SQLMXPreparedStatement \
 		org.apache.trafodion.jdbc.t2.SQLMXResultSet \
+		org.apache.trafodion.jdbc.t2.SQLMXClobReader \
+		org.apache.trafodion.jdbc.t2.SQLMXClobWriter \
+		org.apache.trafodion.jdbc.t2.SQLMXLobInputStream \
+		org.apache.trafodion.jdbc.t2.SQLMXLobOutputStream \
 		org.apache.trafodion.jdbc.t2.SQLMXStatement
 OBJS = $(COMMON_OBJS) $(T2_OBJS)
 MXODIR = $(TRAF_HOME)/../conn/odbc/src/odbc
diff --git a/core/conn/jdbc_type2/native/SQLMXClobReader.cpp b/core/conn/jdbc_type2/native/SQLMXClobReader.cpp
new file mode 100644
index 0000000..82ff81b
--- /dev/null
+++ b/core/conn/jdbc_type2/native/SQLMXClobReader.cpp
@@ -0,0 +1,68 @@
+/**************************************************************************
+ // @@@ 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 @@@
+ **************************************************************************/
+//
+// MODULE: SQLMXClobReader.cpp
+//
+#include <platform_ndcs.h>
+#include <sql.h>
+#include <sqlext.h>
+#include "JdbcDriverGlobal.h"
+#include "org_apache_trafodion_jdbc_t2_SQLMXClobReader.h"
+#include "SQLMXCommonFunctions.h"
+#include "CoreCommon.h"
+#include "SrvrCommon.h"
+#include "SrvrOthers.h"
+#include "CSrvrConnect.h"
+#include "Debug.h"
+#include "GlobalInformation.h"
+#include "sqlcli.h"
+
+JNIEXPORT jint JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXClobReader_readChunk
+  (JNIEnv *jenv, jobject jobj, jstring jServer, jlong jDialogueId, jint jExtractMode, jstring jLobLocator, jobject jCharBuffer)
+{
+   odbc_SQLsrvr_ExtractLob_exc_ exception = {0,0,0};
+   BYTE *chunkBuf = (BYTE *)jenv->GetDirectBufferAddress(jCharBuffer);
+   jlong jLength = jenv->GetDirectBufferCapacity(jCharBuffer);
+   const char *lobLocator = jenv->GetStringUTFChars(jLobLocator, NULL);
+   IDL_long_long  lobLength = 0; // Used when extractMode is 0 
+   IDL_long_long  extractLen = jLength;
+
+   odbc_SQLSrvr_ExtractLob_sme_(NULL, NULL, &exception, jDialogueId, jExtractMode, 
+                (IDL_char *)lobLocator, lobLength, extractLen, chunkBuf);
+   jenv->ReleaseStringUTFChars(jLobLocator, lobLocator);
+   switch (exception.exception_nr) {
+      case CEE_SUCCESS:
+         return extractLen;
+      case odbc_SQLSvc_ExtractLob_SQLError_exn_:
+         throwSQLException(jenv, &exception.u.SQLError);
+         break;
+      case odbc_SQLSvc_ExtractLob_SQLInvalidhandle_exn_:
+         throwSQLException(jenv, MODULE_ERROR, exception.u.ParamError.ParamDesc, "HY000");
+         break;
+      case odbc_SQLSvc_ExtractLob_InvalidConnect_exn_:
+      default:
+         throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception.exception_nr);
+         break;
+   }
+   return -1;
+}
diff --git a/core/conn/jdbc_type2/native/SQLMXClobWriter.cpp b/core/conn/jdbc_type2/native/SQLMXClobWriter.cpp
new file mode 100644
index 0000000..b664663
--- /dev/null
+++ b/core/conn/jdbc_type2/native/SQLMXClobWriter.cpp
@@ -0,0 +1,68 @@
+/**************************************************************************
+ // @@@ 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 @@@
+ **************************************************************************/
+//
+// MODULE: SQLMXClobWriter.cpp
+//
+#include <platform_ndcs.h>
+#include <sql.h>
+#include <sqlext.h>
+#include "JdbcDriverGlobal.h"
+#include "org_apache_trafodion_jdbc_t2_SQLMXClobWriter.h"
+#include "SQLMXCommonFunctions.h"
+#include "CoreCommon.h"
+#include "SrvrCommon.h"
+#include "SrvrOthers.h"
+#include "CSrvrConnect.h"
+#include "Debug.h"
+#include "GlobalInformation.h"
+#include "sqlcli.h"
+
+JNIEXPORT void JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXClobWriter_writeChunk
+  (JNIEnv *jenv, jobject jobj, jstring jServer, jlong jDialogueId, jlong jTxId, jstring jLobLocator, jstring jChunk, jlong jPos)
+{
+   odbc_SQLSvc_UpdateLob_exc_ exception = {0,0,0};
+   const char *chunkStr = jenv->GetStringUTFChars(jChunk, NULL);
+   long chunkLen = jenv->GetStringUTFLength(jChunk);
+   const char *lobLocator = jenv->GetStringUTFChars(jLobLocator, NULL);
+
+   odbc_SQLSrvr_UpdateLob_sme_(NULL, NULL, &exception, jDialogueId, 
+                (IDL_char *)lobLocator, 0, jPos, chunkLen, (BYTE *)chunkStr);
+   jenv->ReleaseStringUTFChars(jLobLocator, lobLocator);
+   jenv->ReleaseStringUTFChars(jChunk, chunkStr);
+   switch (exception.exception_nr) {
+      case CEE_SUCCESS:
+         break;
+      case odbc_SQLSvc_UpdateLob_SQLError_exn_:
+         throwSQLException(jenv, &exception.u.SQLError);
+         break;
+      case odbc_SQLSvc_UpdateLob_ParamError_exn_:
+      case odbc_SQLSvc_UpdateLob_SQLInvalidhandle_exn_:
+         throwSQLException(jenv, MODULE_ERROR, exception.u.ParamError.ParamDesc, "HY000");
+         break;
+      case odbc_SQLSvc_UpdateLob_InvalidConnect_exn_:
+      default:
+         throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception.exception_nr);
+         break;
+   }
+   return ;
+}
diff --git a/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp b/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp
index 9151076..bcac9c5 100644
--- a/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp
+++ b/core/conn/jdbc_type2/native/SQLMXCommonFunctions.cpp
@@ -1611,6 +1611,8 @@
 						case SQLTYPECODE_VARCHAR_LONG:
 						case SQLTYPECODE_DATETIME:
 						case SQLTYPECODE_INTERVAL:
+						case SQLTYPECODE_CLOB:
+						case SQLTYPECODE_BLOB:
 							if ((IPD[paramNumber + paramOffset].vc_ind_length == 4) && (allocLength > dataLen + sizeof(int)))
 							{
 							    *(unsigned int *)dataPtr = (int)dataLen;
@@ -1749,7 +1751,8 @@
 		case SQLTYPECODE_VARCHAR:
 		case SQLTYPECODE_VARCHAR_LONG:
 		case SQLTYPECODE_VARCHAR_WITH_LENGTH:
-
+		case SQLTYPECODE_CLOB:
+		case SQLTYPECODE_BLOB:		
 			if ( useDefaultCharsetEncoding(wrapperInfo->jenv, jobj, charSet, iso88591Encoding) )
 			{
 				encoding = NULL;
@@ -2022,6 +2025,8 @@
 			break;
 		case SQLTYPECODE_VARCHAR_WITH_LENGTH:
 		case SQLTYPECODE_VARCHAR_LONG:
+		case SQLTYPECODE_CLOB:
+		case SQLTYPECODE_BLOB:
 		case SQLTYPECODE_DATETIME:
 		case SQLTYPECODE_INTERVAL:
 			if (vcIndLength == 4 && targetLength > dataLen+sizeof(int))
@@ -2101,6 +2106,8 @@
 		case SQLTYPECODE_VARCHAR:
 		case SQLTYPECODE_VARCHAR_LONG:
 		case SQLTYPECODE_VARCHAR_WITH_LENGTH:
+		case SQLTYPECODE_CLOB:
+		case SQLTYPECODE_BLOB:
 			if (nParamValue != NULL)
 			{
 				JNI_ReleaseByteArrayElements(wrapperInfo->jenv,stringByteArray, (jbyte *)nParamValue, JNI_ABORT);
@@ -3232,6 +3239,15 @@
 				*(strDataPtr + DataLen) = '\0';
 			usejchar = TRUE;
 			break;
+		case SQLTYPECODE_CLOB:
+		case SQLTYPECODE_BLOB:
+			strDataPtr = (char *)SQLValue->dataValue._buffer + sizeof(short);
+			DataLen = *(short *)SQLValue->dataValue._buffer;
+			// Null terminate only if ISO88591
+			if(nullRequired(SQLValue->dataCharset))
+				*(strDataPtr + DataLen) = '\0';
+			usejchar = TRUE;
+			break;
 		case SQLTYPECODE_VARCHAR_WITH_LENGTH:
 		case SQLTYPECODE_VARCHAR_LONG:
 		case SQLTYPECODE_INTERVAL:
diff --git a/core/conn/jdbc_type2/native/SQLMXLobInputStream.cpp b/core/conn/jdbc_type2/native/SQLMXLobInputStream.cpp
new file mode 100644
index 0000000..c447598
--- /dev/null
+++ b/core/conn/jdbc_type2/native/SQLMXLobInputStream.cpp
@@ -0,0 +1,68 @@
+/**************************************************************************
+ // @@@ 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 @@@
+ **************************************************************************/
+//
+// MODULE: SQLMXLobInputStream.cpp
+//
+#include <platform_ndcs.h>
+#include <sql.h>
+#include <sqlext.h>
+#include "JdbcDriverGlobal.h"
+#include "org_apache_trafodion_jdbc_t2_SQLMXLobInputStream.h"
+#include "SQLMXCommonFunctions.h"
+#include "CoreCommon.h"
+#include "SrvrCommon.h"
+#include "SrvrOthers.h"
+#include "CSrvrConnect.h"
+#include "Debug.h"
+#include "GlobalInformation.h"
+#include "sqlcli.h"
+
+JNIEXPORT jint JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXLobInputStream_readChunk
+  (JNIEnv *jenv, jobject jobj, jstring jServer, jlong jDialogueId, jint jExtractMode, jstring jLobLocator, jobject jByteBuffer)
+{
+   odbc_SQLsrvr_ExtractLob_exc_ exception = {0,0,0};
+   BYTE *chunkBuf = (BYTE *)jenv->GetDirectBufferAddress(jByteBuffer);
+   jlong jLength = jenv->GetDirectBufferCapacity(jByteBuffer);
+   const char *lobLocator = jenv->GetStringUTFChars(jLobLocator, NULL);
+   IDL_long_long  lobLength = 0; // Used when extractMode is 0 
+   IDL_long_long  extractLen = jLength;
+
+   odbc_SQLSrvr_ExtractLob_sme_(NULL, NULL, &exception, jDialogueId, jExtractMode, 
+                (IDL_char *)lobLocator, lobLength, extractLen, chunkBuf);
+   jenv->ReleaseStringUTFChars(jLobLocator, lobLocator);
+   switch (exception.exception_nr) {
+      case CEE_SUCCESS:
+         return extractLen;
+      case odbc_SQLSvc_ExtractLob_SQLError_exn_:
+         throwSQLException(jenv, &exception.u.SQLError);
+         break;
+      case odbc_SQLSvc_ExtractLob_SQLInvalidhandle_exn_:
+         throwSQLException(jenv, MODULE_ERROR, exception.u.ParamError.ParamDesc, "HY000");
+         break;
+      case odbc_SQLSvc_ExtractLob_InvalidConnect_exn_:
+      default:
+         throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception.exception_nr);
+         break;
+   }
+   return -1;
+}
diff --git a/core/conn/jdbc_type2/native/SQLMXLobOutputStream.cpp b/core/conn/jdbc_type2/native/SQLMXLobOutputStream.cpp
new file mode 100644
index 0000000..145a470
--- /dev/null
+++ b/core/conn/jdbc_type2/native/SQLMXLobOutputStream.cpp
@@ -0,0 +1,68 @@
+/**************************************************************************
+ // @@@ 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 @@@
+ **************************************************************************/
+//
+// MODULE: SQLMXLobInputStream.cpp
+//
+#include <platform_ndcs.h>
+#include <sql.h>
+#include <sqlext.h>
+#include "JdbcDriverGlobal.h"
+#include "org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream.h"
+#include "SQLMXCommonFunctions.h"
+#include "CoreCommon.h"
+#include "SrvrCommon.h"
+#include "SrvrOthers.h"
+#include "CSrvrConnect.h"
+#include "Debug.h"
+#include "GlobalInformation.h"
+#include "sqlcli.h"
+
+JNIEXPORT void JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream_writeChunk
+  (JNIEnv *jenv, jobject jobj, jstring jServer, jlong jDialogueId, jlong jTxId, jstring jLobLocator, jbyteArray jChunk, 
+                         jint jOffset, jint jLength, jlong jPos)
+{
+   odbc_SQLSvc_UpdateLob_exc_ exception = {0,0,0};
+   BYTE *chunkBuf = new BYTE[jLength];
+   jenv->GetByteArrayRegion(jChunk, jOffset, jLength, (jbyte *)chunkBuf); 
+   const char *lobLocator = jenv->GetStringUTFChars(jLobLocator, NULL);
+
+   odbc_SQLSrvr_UpdateLob_sme_(NULL, NULL, &exception, jDialogueId, 
+                (IDL_char *)lobLocator, 0, jPos, jLength, chunkBuf);
+   delete chunkBuf;
+   jenv->ReleaseStringUTFChars(jLobLocator, lobLocator);
+   switch (exception.exception_nr) {
+      case CEE_SUCCESS:
+         break;
+      case odbc_SQLSvc_UpdateLob_SQLError_exn_:
+         throwSQLException(jenv, &exception.u.SQLError);
+         break;
+      case odbc_SQLSvc_UpdateLob_ParamError_exn_:
+      case odbc_SQLSvc_UpdateLob_SQLInvalidhandle_exn_:
+         throwSQLException(jenv, MODULE_ERROR, exception.u.ParamError.ParamDesc, "HY000");
+         break;
+      case odbc_SQLSvc_UpdateLob_InvalidConnect_exn_:
+      default:
+         throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception.exception_nr);
+         break;
+   }
+}
diff --git a/core/conn/jdbc_type2/native/SqlInterface.cpp b/core/conn/jdbc_type2/native/SqlInterface.cpp
index 1076fb3..1484edb 100644
--- a/core/conn/jdbc_type2/native/SqlInterface.cpp
+++ b/core/conn/jdbc_type2/native/SqlInterface.cpp
@@ -330,6 +330,16 @@
 			&allocSize,
 			NULL);
 		break;
+	case SQLTYPECODE_CLOB:
+		SQLItemDesc->ODBCDataType  = TYPE_CLOB;
+		SQLItemDesc->signType      = FALSE;
+		SQLItemDesc->ODBCPrecision = 0;
+	        break;	
+	case SQLTYPECODE_BLOB:
+		SQLItemDesc->ODBCDataType  = TYPE_BLOB;
+		SQLItemDesc->signType      = FALSE;
+		SQLItemDesc->ODBCPrecision = 0;
+		break;
 	case SQLTYPECODE_BIT:
 	case SQLTYPECODE_BITVAR:
 	case SQLTYPECODE_IEEE_FLOAT:
@@ -3451,6 +3461,16 @@
 			break;
 		}
 		break;
+	case SQLTYPECODE_CLOB:
+		ODBCPrecision = Length;
+		ODBCDataType = TYPE_CLOB;
+		strcpy(DataTypeString, "CLOB");
+		break;	
+	case SQLTYPECODE_BLOB:
+		ODBCPrecision = Length;
+		ODBCDataType = TYPE_BLOB;
+		strcpy(DataTypeString, "BLOB");
+		break;	
 	default:
 		ODBCDataType = SQL_TYPE_NULL;
 		ODBCPrecision = 0;
diff --git a/core/conn/jdbc_type2/native/SrvrCommon.cpp b/core/conn/jdbc_type2/native/SrvrCommon.cpp
index 148b06e..8db4032 100644
--- a/core/conn/jdbc_type2/native/SrvrCommon.cpp
+++ b/core/conn/jdbc_type2/native/SrvrCommon.cpp
@@ -1812,6 +1812,8 @@
     {
     case SQLTYPECODE_CHAR:
     case SQLTYPECODE_VARCHAR:
+    case SQLTYPECODE_CLOB:
+    case SQLTYPECODE_BLOB:
         if( nullRequired(char_set) )
             varNulls = 1;
         break;
diff --git a/core/conn/jdbc_type2/native/SrvrOthers.cpp b/core/conn/jdbc_type2/native/SrvrOthers.cpp
index 08d8a7c..a436c8c 100644
--- a/core/conn/jdbc_type2/native/SrvrOthers.cpp
+++ b/core/conn/jdbc_type2/native/SrvrOthers.cpp
@@ -1529,3 +1529,139 @@
     }
     FUNCTION_RETURN_VOID((NULL));
 }
+
+extern "C" void
+odbc_SQLSrvr_ExtractLob_sme_(
+    /* In    */ void *objtag_
+  , /* In    */ const CEE_handle_def *call_id_
+  , /* Out   */ odbc_SQLsrvr_ExtractLob_exc_ *exception_
+  , /* In    */ long dialogueId
+  , /* In    */ IDL_short extractLobAPI
+  , /* In    */ IDL_string lobHandle
+  , /* In    */ IDL_long_long &lobLength
+  , /* Out   */ IDL_long_long &extractLen
+  , /* Out   */ BYTE *& extractData
+  )
+{
+    char lobExtractQuery[1000] = {0};
+    char RequestError[200] = {0};
+    long sqlcode;
+    SRVR_STMT_HDL  *QryLobExtractSrvrStmt = NULL;
+
+    if ((QryLobExtractSrvrStmt = createSrvrStmt(dialogueId, "MXOSRVR_EXTRACTLOB", &sqlcode, 
+			NULL, 0, 0, TYPE_UNKNOWN, false,true)) == NULL) 
+    {
+       exception_->exception_nr = odbc_SQLSvc_ExtractLob_SQLInvalidhandle_exn_;
+       return;
+    }
+    switch (extractLobAPI) {
+    case 0:
+        snprintf(lobExtractQuery, sizeof(lobExtractQuery), "EXTRACT LOBLENGTH(LOB'%s') LOCATION %Ld", lobHandle, (Int64)&lobLength);
+        break;
+    case 1:
+        extractData = new BYTE[extractLen + 1];
+        if (extractData == NULL)
+        {
+            exception_->exception_nr = odbc_SQLSvc_ExtractLob_ParamError_exn_;
+            exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_BUFFER_ALLOC_FAILED;
+	    return;
+        }
+
+        snprintf(lobExtractQuery, sizeof(lobExtractQuery), "EXTRACT LOBTOBUFFER(LOB'%s', LOCATION %Ld, SIZE %Ld)", lobHandle, (Int64)extractData, &extractLen);
+        break;
+    case 2:
+        extractLen = 0;
+        extractData = NULL;
+        snprintf(lobExtractQuery, sizeof(lobExtractQuery), "EXTRACT LOBTOBUFFER(LOB'%s', LOCATION %Ld, SIZE %Ld)", lobHandle, (Int64)extractData, &extractLen);
+        break;
+    default:
+        return ;
+    }
+    SQLValue_def sqlStringValue;
+    sqlStringValue.dataValue._buffer = (unsigned char *)lobExtractQuery;
+    sqlStringValue.dataValue._length = strlen(lobExtractQuery);
+    sqlStringValue.dataCharset = 0;
+    sqlStringValue.dataType = SQLTYPECODE_VARCHAR;
+    sqlStringValue.dataInd = 0;
+
+    try
+    {
+        short retcode = QryLobExtractSrvrStmt->ExecDirect(NULL, &sqlStringValue, EXTERNAL_STMT, TYPE_CALL, SQL_ASYNC_ENABLE_OFF, 0);
+
+        if (retcode == SQL_ERROR)
+        {
+            ERROR_DESC_def *p_buffer = QryLobExtractSrvrStmt->sqlError.errorList._buffer;
+            exception_->exception_nr = odbc_SQLSvc_ExtractLob_SQLError_exn_;
+            exception_->u.SQLError.errorList._length = QryLobExtractSrvrStmt->sqlError.errorList._length;
+            exception_->u.SQLError.errorList._buffer = QryLobExtractSrvrStmt->sqlError.errorList._buffer;
+        }
+    }
+    catch (...)
+    {
+        exception_->exception_nr = odbc_SQLSvc_ExtractLob_ParamError_exn_;
+        exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_EXECDIRECT_FAILED;
+    }
+    if (QryLobExtractSrvrStmt != NULL) 
+        QryLobExtractSrvrStmt->Close(SQL_DROP);
+
+}
+
+extern "C" void
+odbc_SQLSrvr_UpdateLob_sme_(
+    /* In   */ void *objtag_
+  , /* In   */ const CEE_handle_def * call_id_
+  , /* In   */ odbc_SQLSvc_UpdateLob_exc_ * exception_
+  , /* In   */ long dialogueId
+  , /* In   */ IDL_string lobHandle
+  , /* In   */ IDL_long_long totalLength
+  , /* In   */ IDL_long_long offset
+  , /* In   */ IDL_long_long length
+  , /* In   */ BYTE * data)
+{
+    char lobUpdateQuery[1000] = {0};
+    char RequestError[200] = {0};
+    long sqlcode;
+
+    SRVR_STMT_HDL * QryLobUpdateSrvrStmt = NULL;
+
+    if ((QryLobUpdateSrvrStmt = createSrvrStmt(dialogueId, "MXOSRVR_UPDATELOB", &sqlcode, 
+			NULL, 0, 0, TYPE_UNKNOWN, false,true)) == NULL) {
+        exception_->exception_nr = odbc_SQLSvc_UpdateLob_SQLInvalidhandle_exn_;
+	return;
+    }
+
+    if (offset == 0) {
+        snprintf(lobUpdateQuery, sizeof(lobUpdateQuery),  "UPDATE LOB (LOB'%s', LOCATION %Ld, SIZE %Ld)", lobHandle, (Int64)data, length);
+    } else {
+        snprintf(lobUpdateQuery, sizeof(lobUpdateQuery),  "UPDATE LOB (LOB'%s', LOCATION %Ld, SIZE %Ld, APPEND)", lobHandle, (Int64)data, length);
+    }
+
+    SQLValue_def sqlStringValue;
+    sqlStringValue.dataValue._buffer = (unsigned char *)lobUpdateQuery;
+    sqlStringValue.dataValue._length = strlen(lobUpdateQuery);
+    sqlStringValue.dataCharset = 0;
+    sqlStringValue.dataType = SQLTYPECODE_VARCHAR;
+    sqlStringValue.dataInd = 0;
+                                
+    short retcode = 0;
+    try {
+       retcode = QryLobUpdateSrvrStmt->ExecDirect(NULL, &sqlStringValue, EXTERNAL_STMT, TYPE_UNKNOWN, SQL_ASYNC_ENABLE_OFF, 0);
+
+       if (retcode == SQL_ERROR) {
+           exception_->exception_nr = odbc_SQLSvc_UpdateLob_SQLError_exn_;
+           exception_->u.SQLError.errorList._length = QryLobUpdateSrvrStmt->sqlError.errorList._length;
+           exception_->u.SQLError.errorList._buffer = QryLobUpdateSrvrStmt->sqlError.errorList._buffer;
+       }
+    }
+    catch (...)
+    {
+        exception_->exception_nr = odbc_SQLSvc_UpdateLob_ParamError_exn_;
+        exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_EXECUTE_FAILED;
+    }
+
+    if (QryLobUpdateSrvrStmt != NULL) {
+        QryLobUpdateSrvrStmt->Close(SQL_DROP);
+    }
+    return;
+}
+
diff --git a/core/conn/jdbc_type2/native/SrvrOthers.h b/core/conn/jdbc_type2/native/SrvrOthers.h
index 26cb37c..e78e563 100644
--- a/core/conn/jdbc_type2/native/SrvrOthers.h
+++ b/core/conn/jdbc_type2/native/SrvrOthers.h
@@ -380,6 +380,84 @@
 								, /* In    */ const char *fktableNm
 								);
 
+/***************************************
+ *  * Operation 'odbc_SQLsrvr_ExtractLob'
+ *   * *************************************/
+/*
+ *  * Exception number constants for
+ *   * operation 'odbc_SQLsrvr_ExtractLob'
+ *    */
+
+#define odbc_SQLSvc_ExtractLob_ParamError_exn_        1
+#define odbc_SQLSvc_ExtractLob_InvalidConnect_exn_ 2
+#define odbc_SQLSvc_ExtractLob_SQLError_exn_ 3
+#define odbc_SQLSvc_ExtractLob_SQLInvalidhandle_exn_ 4
+#define obdc_SQLSvc_ExtractLob_AllocLOBDataError_exn_ 5
+
+/*
+ *  * Exception struct for
+ *   * Operation "odbc_SQLSrvr_ExtractLob"
+ *    */
+struct odbc_SQLsrvr_ExtractLob_exc_ {
+    IDL_long exception_nr;
+    IDL_long exception_detail;
+    union {
+        odbc_SQLSvc_ParamError ParamError;
+        odbc_SQLSvc_SQLError SQLError;
+    } u;
+};
+
+/***************************************
+ *  * Operation 'odbc_SQLsvc_UpdateLob'
+ *   ***************************************/
+/*
+ *  * Exceptoin number constants for
+ *   * operation 'odbc_SQLSvc_UpdateLob'
+ *                                           
+ *                                            */
+#define odbc_SQLSvc_UpdateLob_ParamError_exn_        1
+#define odbc_SQLSvc_UpdateLob_InvalidConnect_exn_    2
+#define odbc_SQLSvc_UpdateLob_SQLError_exn_          3
+#define odbc_SQLSvc_UpdateLob_SQLInvalidhandle_exn_  4
+
+/*
+ *  * Exception struct for
+ *   * Operation "odbc_SQLSvc_UpdateLob"
+ *    */
+struct odbc_SQLSvc_UpdateLob_exc_ {
+  IDL_long exception_nr;
+  IDL_long exception_detail;
+  union {
+    odbc_SQLSvc_ParamError ParamError;
+    odbc_SQLSvc_SQLError   SQLError;
+  } u;
+};
+
+extern "C" void
+odbc_SQLSrvr_ExtractLob_sme_(
+    /* In    */ void *objtag_
+  , /* In    */ const CEE_handle_def *call_id_
+  , /* In    */ odbc_SQLsrvr_ExtractLob_exc_ *exception_
+  , /* In    */ long dialogueId
+  , /* In    */ IDL_short extractLobAPI
+  , /* In    */ IDL_string lobHandle
+  , /* In    */ IDL_long_long &lobLength
+  , /* Out   */ IDL_long_long &extractLen
+  , /* Out   */ BYTE *& extractData);
+
+extern "C" void
+odbc_SQLSrvr_UpdateLob_sme_(
+    /* In   */ void *objtag_
+  , /* In   */ const CEE_handle_def * call_id_
+  , /* In   */ odbc_SQLSvc_UpdateLob_exc_  *exception_
+  , /* In    */ long dialogueId
+  , /* In   */ IDL_string lobHandle
+  , /* In   */ IDL_long_long totalLength
+  , /* In   */ IDL_long_long offset
+  , /* In   */ IDL_long_long length
+  , /* In   */ BYTE * data);
+
+
 //extern std::map<std::string, std::string> mapOfSQLToModuleFile;
 
 #endif // _SRVROTHERS_DEFINED
diff --git a/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXClobReader.h b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXClobReader.h
new file mode 100644
index 0000000..1eaf8fb
--- /dev/null
+++ b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXClobReader.h
@@ -0,0 +1,23 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_apache_trafodion_jdbc_t2_SQLMXClobReader */
+
+#ifndef _Included_org_apache_trafodion_jdbc_t2_SQLMXClobReader
+#define _Included_org_apache_trafodion_jdbc_t2_SQLMXClobReader
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef org_apache_trafodion_jdbc_t2_SQLMXClobReader_maxSkipBufferSize
+#define org_apache_trafodion_jdbc_t2_SQLMXClobReader_maxSkipBufferSize 8192L
+/*
+ * Class:     org_apache_trafodion_jdbc_t2_SQLMXClobReader
+ * Method:    readChunk
+ * Signature: (Ljava/lang/String;JJJLjava/lang/String;Ljava/nio/CharBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXClobReader_readChunk
+  (JNIEnv *, jobject, jstring, jlong, jlong, jlong, jstring, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXClobWriter.h b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXClobWriter.h
new file mode 100644
index 0000000..06e7c53
--- /dev/null
+++ b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXClobWriter.h
@@ -0,0 +1,23 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_apache_trafodion_jdbc_t2_SQLMXClobWriter */
+
+#ifndef _Included_org_apache_trafodion_jdbc_t2_SQLMXClobWriter
+#define _Included_org_apache_trafodion_jdbc_t2_SQLMXClobWriter
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef org_apache_trafodion_jdbc_t2_SQLMXClobWriter_WRITE_BUFFER_SIZE
+#define org_apache_trafodion_jdbc_t2_SQLMXClobWriter_WRITE_BUFFER_SIZE 1024L
+/*
+ * Class:     org_apache_trafodion_jdbc_t2_SQLMXClobWriter
+ * Method:    writeChunk
+ * Signature: (Ljava/lang/String;JJLjava/lang/String;Ljava/lang/String;J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXClobWriter_writeChunk
+  (JNIEnv *, jobject, jstring, jlong, jlong, jstring, jstring, jlong);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXLobInputStream.h b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXLobInputStream.h
new file mode 100644
index 0000000..9185dda
--- /dev/null
+++ b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXLobInputStream.h
@@ -0,0 +1,23 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_apache_trafodion_jdbc_t2_SQLMXLobInputStream */
+
+#ifndef _Included_org_apache_trafodion_jdbc_t2_SQLMXLobInputStream
+#define _Included_org_apache_trafodion_jdbc_t2_SQLMXLobInputStream
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef org_apache_trafodion_jdbc_t2_SQLMXLobInputStream_MAX_SKIP_BUFFER_SIZE
+#define org_apache_trafodion_jdbc_t2_SQLMXLobInputStream_MAX_SKIP_BUFFER_SIZE 2048L
+/*
+ * Class:     org_apache_trafodion_jdbc_t2_SQLMXLobInputStream
+ * Method:    readChunk
+ * Signature: (Ljava/lang/String;JJJLjava/lang/String;Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXLobInputStream_readChunk
+  (JNIEnv *, jobject, jstring, jlong, jlong, jlong, jstring, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream.h b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream.h
new file mode 100644
index 0000000..9de819e
--- /dev/null
+++ b/core/conn/jdbc_type2/native/org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream.h
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream */
+
+#ifndef _Included_org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream
+#define _Included_org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class:     org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream
+ * Method:    writeChunk
+ * Signature: (Ljava/lang/String;JJLjava/lang/String;[BIIJ)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_trafodion_jdbc_t2_SQLMXLobOutputStream_writeChunk
+  (JNIEnv *, jobject, jstring, jlong, jlong, jstring, jbyteArray, jint, jint, jlong);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/DataWrapper.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/DataWrapper.java
index f0609ec..46bf051 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/DataWrapper.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/DataWrapper.java
@@ -2120,6 +2120,7 @@
 				else
 				{
 					obj = getObject(col_idx+1);
+/* TODO: Selva
 					if (obj instanceof SQLMXLob)
 					{
 						if (orig_obj==this)
@@ -2129,6 +2130,7 @@
 							continue;
 						}
 					}
+*/
 					updateStmt.setObject(++param_idx, obj);
 				}
 			}
@@ -2197,7 +2199,7 @@
 		}
 	}
 
-	void closeLobObjects()
+	void closeLobObjects() throws SQLException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_closeLobObjects].methodEntry();
 		try
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXBlob.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXBlob.java
index 3bbdf4a..7360116 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXBlob.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXBlob.java
@@ -34,6 +34,7 @@
 import java.io.Writer;
 import java.util.Date;
 import java.io.PrintWriter;
+import java.io.ByteArrayInputStream;
 
 public class SQLMXBlob extends SQLMXLob implements Blob 
 {
@@ -54,6 +55,7 @@
 
 	public byte[] getBytes(long pos, int length) throws SQLException
 	{
+/*
 		if (JdbcDebugCfg.entryActive) debug[methodId_getBytes].methodEntry();
 		try
 		{
@@ -153,10 +155,13 @@
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_getBytes].methodExit();
 		}
+*/
+		return null;
 	}
 
 	public long position(Blob pattern, long start) throws SQLException
 	{
+/*
 		if (JdbcDebugCfg.entryActive) debug[methodId_position_LJ].methodEntry();
 		try
 		{
@@ -176,10 +181,13 @@
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_position_LJ].methodExit();
 		}
+*/
+		return 0;
 	}
 
 	public long position(byte[] pattern, long start) throws SQLException
 	{
+/*
 		if (JdbcDebugCfg.entryActive) debug[methodId_position_BJ].methodEntry();
 		try
 		{
@@ -204,6 +212,8 @@
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_position_BJ].methodExit();
 		}
+*/
+		return 0;
 	}
 
 
@@ -247,162 +257,17 @@
 		if (JdbcDebugCfg.entryActive) debug[methodId_setBytes_JBII].methodEntry();
 		try
 		{
-			int endChunkNo;
-			int updOffset;
-			int updLen;
-			int	chunkNo;
-			long lobLenForUpd;
-			int	 byteOffset;
-			int retLen;
-			int totalRetLen;
-			int copyLen;
-			long remLen;
-			long lobLen;
-
-			byte [] tempChunk = null;
-
-			if (pos <= 0 || len < 0 || offset < 0 || bytes == null) 
+			if (pos > 1 || len < 0 || offset < 0 || bytes == null) 
 			{
 				Object[] messageArguments = new Object[1];
 				messageArguments[0] = "Blob.setBytes(long, byte[], int, int)";
 				throw Messages.createSQLException(conn_.locale_,"invalid_input_value", messageArguments);
 			}
 			checkIfCurrent();
-			lobLen = length();
-			if (pos > lobLen+1)
-				throw Messages.createSQLException(conn_.locale_,"invalid_position_value", null);
-			copyLen = len;
-			remLen = pos-1+len;	// Length to be either updated or inserted
-			byteOffset = offset;
-			totalRetLen = 0;
-			chunkNo = (int)((pos-1)/ chunkSize_);
-			// calculate the length that can be updated rounded to chunk size
-			if ((lobLen % chunkSize_) == 0)
-				lobLenForUpd = (lobLen / chunkSize_) * chunkSize_;
-			else
-				lobLenForUpd = ((lobLen / chunkSize_)+1) * chunkSize_;
-			if (remLen <= lobLenForUpd)
-				updLen	= len;
-			else
-				updLen = (int)(lobLenForUpd - (pos-1));
-			if (updLen > 0)
-			{
-				updOffset = (int)((pos-1) % chunkSize_);
-				prepareUpdLobDataStmt();		
-
-				synchronized (conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT])
-				{
-					conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setString(4, tableName_);
-					conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setLong(5, dataLocator_);
-				
-					while (true)
-					{
-						// String is 0 based while substring in SQL/MX is 1 based, hence +1
-						conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setInt(6, chunkNo);
-						conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setInt(1, updOffset);
-						if ((updOffset + updLen) <= chunkSize_)
-						{
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setInt(3, updOffset + updLen + 1);
-							if ((byteOffset == 0) && (updLen - updOffset == bytes.length))
-							{
-								conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setBytes(2, bytes);
-							}
-							else
-							{
-								tempChunk = new byte[updLen];
-								System.arraycopy(bytes, byteOffset, tempChunk, 0, updLen);
-								conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setBytes(2, tempChunk);
-							}
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].executeUpdate();
-							totalRetLen += updLen;
-							byteOffset += updLen;
-							chunkNo++;
-							break;
-						}
-						else
-						{
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setInt(3, chunkSize_+1);
-							if (tempChunk == null || tempChunk.length != chunkSize_-updOffset)
-								tempChunk = new byte[chunkSize_-updOffset];
-							System.arraycopy(bytes, byteOffset, tempChunk, 0, chunkSize_-updOffset);
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].setBytes(2, tempChunk);
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT].executeUpdate();
-							totalRetLen += (chunkSize_-updOffset);
-							byteOffset += (chunkSize_-updOffset);
-							updLen -= (chunkSize_-updOffset);
-							chunkNo++;
-						}
-						updOffset = 0;
-					}
-				}
-				copyLen = (int)(remLen - lobLenForUpd);
-				
-				if ((traceWriter_ != null) && 
-					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-				{
-					traceWriter_.println(getTraceId() 
-						+ "setBytes(" + pos + ",<bytes>," + offset + "," + len 
-						+ ") - UpdLobDataStmt params: tableName_=" + tableName_ 
-						+ " dataLocator_=" + dataLocator_ + " chunkNo=" + chunkNo
-						+ " updOffset=" + updOffset + " updLen=" + updLen
-						+ " remLen=" + remLen + " lobLenForUpd=" + lobLenForUpd 
-						+ " byteOffset=" + byteOffset + " totalRetLen=" + totalRetLen);
-				}
-			}
-
-			tempChunk = null;
-			if (remLen > lobLenForUpd)
-			{
-				while (true)
-				{
-					prepareInsLobDataStmt();
-
-					synchronized (conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT])
-					{
-						conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setString(1, tableName_);
-						conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setLong(2, dataLocator_);
-						conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setInt(3, chunkNo);
-						if (copyLen <= chunkSize_)
-						{
-							if (byteOffset == 0 && copyLen == bytes.length)
-								conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setBytes(4, bytes);
-							else
-							{
-								tempChunk = new byte[copyLen];
-								System.arraycopy(bytes, byteOffset, tempChunk, 0, copyLen);
-								conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setBytes(4, tempChunk);
-							}
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].executeUpdate();
-							totalRetLen += copyLen;
-							break;
-						}
-						else
-						{
-							if (tempChunk == null)
-								tempChunk = new byte[chunkSize_];
-							System.arraycopy(bytes, byteOffset, tempChunk, 0, chunkSize_);
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setBytes(4, tempChunk);
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].executeUpdate();
-							byteOffset += chunkSize_;
-							copyLen -= chunkSize_;
-							totalRetLen += chunkSize_;
-						}
-						chunkNo++;
-					}
-				}
-				
-				if ((traceWriter_ != null) && 
-					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-				{
-					traceWriter_.println(getTraceId() 
-						+ "setBytes(" + pos + ",<bytes>," + offset + "," + len 
-						+ ") - InsLobDataStmt params: tableName_=" + tableName_ 
-						+ " dataLocator_=" + dataLocator_ + " (total)chunkNo=" + chunkNo
-						+ " copyLen=" + copyLen + " byteOffset=" + byteOffset 
-						+ " totalRetLen=" + totalRetLen);
-				}
-			}
-			return totalRetLen;
+			is_ = new ByteArrayInputStream(bytes, offset, len);
+			isLength_ = len;
+			populate();
+			return len-offset;
 		}
 		finally
 		{
@@ -422,23 +287,18 @@
 		try
 		{
 			SQLMXLobOutputStream os;
-
+			if (inputLob_ != null) {	
+				is_ = inputLob_.getBinaryStream();
+			} else if (b_ != null) {
+				is_ = new ByteArrayInputStream(b_, 0, b_.length);
+				isLength_ = b_.length;
+			}
 			if (is_ != null)
 			{
 				os = (SQLMXLobOutputStream)setOutputStream(1);
 				os.populate(is_, isLength_);
 				is_ = null;
 			}
-			else if (inputLob_ != null)
-			{	
-				populateFromBlob();
-				inputLob_ = null;			
-			}
-			else if (b_ != null)
-			{
-				setBytes(1, b_);
-				b_ = null;
-			}
 		}
 		finally
 		{
@@ -446,94 +306,6 @@
 		}
 	}
 
-	void populateFromBlob() throws SQLException
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_populateFromBlob].methodEntry();
-		try
-		{
-			long		pos;
-			byte[]		b;
-			int			ret;
-			ResultSet	rs;
-			SQLMXBlob	inputBlob;
-			int			chunkNo = 0;
-		
-			pos = 1;
-			if (inputLob_ instanceof SQLMXBlob)
-			{
-				// When SQL/MX supports insert into a table by selecting some other rows in
-				// the same table, we should change the code to do so
-				// Until then, we read a row and write to the same table with different
-				// data locator till all the rows are read 
-				inputBlob = (SQLMXBlob)inputLob_;
-			
-				prepareGetLobDataStmt();
-				prepareInsLobDataStmt();
-
-				if ((traceWriter_ != null) && 
-					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-				{
-					traceWriter_.println(getTraceId() 
-						+ "populateFromBlob() - GetLobDataStmt params: tableName_=" + inputBlob.tableName_ 
-						+ " dataLocator_=" + inputBlob.dataLocator_ + " chunkNo=0");
-				}
-
-				synchronized (conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_DATA_STMT])
-				{
-					conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_DATA_STMT].setString(1, inputBlob.tableName_);
-					conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_DATA_STMT].setLong(2, inputBlob.dataLocator_);
-					conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_DATA_STMT].setInt(3, 0);	// start ChunkNo
-					conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_DATA_STMT].setInt(4, Integer.MAX_VALUE);
-					rs = conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_DATA_STMT].executeQuery();
-					try
-					{
-						synchronized(conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT])
-						{
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setString(1, tableName_);
-							conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setLong(2, dataLocator_);
-		
-							while (rs.next())
-							{
-								b = rs.getBytes(1);
-								conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setInt(3, chunkNo);
-								conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].setBytes(4, b);
-								conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT].executeUpdate();
-								chunkNo++;
-							}
-						}		
-						
-						if ((traceWriter_ != null) && 
-							((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-						{
-							traceWriter_.println(getTraceId() 
-								+ "populateFromBlob() - InsLobDataStmt params: tableName_=" + tableName_ 
-								+ " dataLocator_=" + dataLocator_ + " (total)chunkNo=" + chunkNo);
-						}
-					} 
-					finally 
-					{
-						rs.close();
-					}
-				}
-			}
-			else
-			{
-				while (true)
-				{
-					b = inputLob_.getBytes(pos, chunkSize_);
-					if (b.length == 0)
-						break;
-					ret = setBytes(pos, b);
-					pos += b.length;
-				}
-			}
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_populateFromBlob].methodExit();
-		}
-	}
-
 	static final int findBytes(byte buf[], int off, int len, byte ptrn[])
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_findBytes].methodEntry();
@@ -569,235 +341,29 @@
 		}
 	}
 
-	// The following methods are used to prepare the LOB statement specific 
-	// to BLOB objects, and re-prepares if the lobTableName_ has changed. 
-	void prepareGetLobLenStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobLenStmt].methodEntry();
-		try
-		{
-			conn_.prepareGetLobLenStmt(lobTableName_,true);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobLenStmt].methodExit();
-		}
-	}
-
-	void prepareDelLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareDelLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareDelLobDataStmt(lobTableName_,true);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareDelLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareGetLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareGetLobDataStmt(lobTableName_,true);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareUpdLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareUpdLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareUpdLobDataStmt(lobTableName_,true);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareUpdLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareInsLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareInsLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareInsLobDataStmt(lobTableName_,true);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareInsLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareTrunLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareTrunLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareTrunLobDataStmt(lobTableName_,true);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareTrunLobDataStmt].methodExit();
-		}
-	}
-	
-	// The following methods are used to return the BLOB prepared statement 
-	// from the connection object PS array for population and execution.
-	PreparedStatement getGetLobLenStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobLenStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_LEN_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobLenStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getDelLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getDelLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.BLOB_DEL_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getDelLobDataStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getTrunLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getTrunLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.BLOB_TRUN_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getTrunLobDataStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getInsLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getInsLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.BLOB_INS_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getInsLobDataStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getUpdLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getUpdLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.BLOB_UPD_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getUpdLobDataStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getGetLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.BLOB_GET_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobDataStmt].methodExit();
-		}
-	}
-
-
 	// Constructors
-	SQLMXBlob(SQLMXConnection connection, String tableName, long dataLocator) throws SQLException
+	SQLMXBlob(SQLMXConnection connection, String lobLocator) throws SQLException
 	{
-		super(connection, tableName, dataLocator, connection.blobTableName_, true);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJ].methodEntry();
-		try
-		{
-			if (connection.blobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_blobTableName", null);
-		
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJ].methodExit();
-		}
+		super(connection, lobLocator, true);
 	}
 
-	SQLMXBlob(SQLMXConnection connection, String tableName, long dataLocator, InputStream x, 
-			int length) throws SQLException
+	SQLMXBlob(SQLMXConnection connection, String lobLocator, InputStream x, int length) throws SQLException
 	{
-		super(connection, tableName, dataLocator, x, length, connection.blobTableName_, true);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJLI].methodEntry();
-		try
-		{
-			if (connection.blobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_blobTableName", null);
-	
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJLI].methodExit();
-		}
+		super(connection, lobLocator, x, length, true);
 	}
 
-	SQLMXBlob(SQLMXConnection connection, String tableName, long dataLocator, Blob inputLob) throws SQLException
+	SQLMXBlob(SQLMXConnection connection, String lobLocator, Blob inputLob) throws SQLException
 	{
-		super(connection, tableName, dataLocator, connection.blobTableName_, true);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJL].methodEntry();
-		try
-		{
-			if (connection.blobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_blobTableName", null);
-			inputLob_ = inputLob;
-	
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJL].methodExit();
-		}
+		super(connection, lobLocator, true);
+		inputLob_ = inputLob;
 	}
 	
-	SQLMXBlob(SQLMXConnection connection, String tableName, long dataLocator, byte[] b)
-		throws SQLException
+	SQLMXBlob(SQLMXConnection connection, String lobLocator, byte[] b) throws SQLException
 	{
-		super(connection, tableName, dataLocator, connection.blobTableName_, true);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJB].methodEntry();
-		try
-		{
-			if (connection.blobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_blobTableName", null);
-			b_ = b;
-	
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXBlob_LLJB].methodExit();
-		}
+		super(connection, lobLocator, true);
+		b_ = b;
 	}
+
 	public void setTraceId(String traceId_) {
 		this.traceId_ = traceId_;
 	}
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXCallableStatement.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXCallableStatement.java
index 49ae072..d28fbc5 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXCallableStatement.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXCallableStatement.java
@@ -1406,14 +1406,14 @@
             synchronized (connection_) {
                 validateExecuteInvocation();
                 if (inputDesc_ != null) {
-                    executeCall(connection_.server_, connection_.getDialogueId_(),
-                            connection_.getTxid_(), connection_.autoCommit_,
+                    executeCall(connection_.server_, connection_.getDialogueId(),
+                            connection_.getTxid(), connection_.autoCommit_,
                             connection_.transactionMode_, stmtId_,
                             inputDesc_.length, getParameters(), queryTimeout_,
                             connection_.iso88591EncodingOverride_);
                 } else
-                executeCall(connection_.server_, connection_.getDialogueId_(),
-                        connection_.getTxid_(), connection_.autoCommit_,
+                executeCall(connection_.server_, connection_.getDialogueId(),
+                        connection_.getTxid(), connection_.autoCommit_,
                         connection_.transactionMode_, stmtId_, 0, null,
                         queryTimeout_,
                         connection_.iso88591EncodingOverride_);
@@ -1472,14 +1472,14 @@
             synchronized (connection_) {
                 validateExecuteInvocation();
                 if (inputDesc_ != null) {
-                    executeCall(connection_.server_, connection_.getDialogueId_(),
-                            connection_.getTxid_(), connection_.autoCommit_,
+                    executeCall(connection_.server_, connection_.getDialogueId(),
+                            connection_.getTxid(), connection_.autoCommit_,
                             connection_.transactionMode_, stmtId_,
                             inputDesc_.length, getParameters(), queryTimeout_,
                             connection_.iso88591EncodingOverride_);
                 } else
-                executeCall(connection_.server_, connection_.getDialogueId_(),
-                        connection_.getTxid_(), connection_.autoCommit_,
+                executeCall(connection_.server_, connection_.getDialogueId(),
+                        connection_.getTxid(), connection_.autoCommit_,
                         connection_.transactionMode_, stmtId_, 0, null,
                         queryTimeout_,
                         connection_.iso88591EncodingOverride_);
@@ -1524,14 +1524,14 @@
             synchronized (connection_) {
                 validateExecuteInvocation();
                 if (inputDesc_ != null) {
-                    executeCall(connection_.server_, connection_.getDialogueId_(),
-                            connection_.getTxid_(), connection_.autoCommit_,
+                    executeCall(connection_.server_, connection_.getDialogueId(),
+                            connection_.getTxid(), connection_.autoCommit_,
                             connection_.transactionMode_, stmtId_,
                             inputDesc_.length, getParameters(), queryTimeout_,
                             connection_.iso88591EncodingOverride_);
                 } else
-                executeCall(connection_.server_, connection_.getDialogueId_(),
-                        connection_.getTxid_(), connection_.autoCommit_,
+                executeCall(connection_.server_, connection_.getDialogueId(),
+                        connection_.getTxid(), connection_.autoCommit_,
                         connection_.transactionMode_, stmtId_, 0, null,
                         queryTimeout_,
                         connection_.iso88591EncodingOverride_);
@@ -1669,7 +1669,7 @@
                     JdbcDebug.debugLevelStmt, "paramValues_ = "
                     + paramValues_ + ", returnResultSet_ = "
                     + returnResultSet_ + ", connection_.txid_ = "
-                    + connection_.getTxid_() + ", resultSetMax_ = "
+                    + connection_.getTxid() + ", resultSetMax_ = "
                     + resultSetMax_ + ", resultSetIndex_ = "
                     + resultSetIndex_ + ", isSPJResultSet_ = "
                     + isSPJResultSet_);
@@ -1709,16 +1709,6 @@
         }
     }
 
-    SQLMXCallableStatement(SQLMXConnection connection, String moduleName,
-            int moduleVersion, long moduleTimestamp, String stmtName) {
-        super(connection, moduleName, moduleVersion, moduleTimestamp, stmtName,
-                false, connection.holdability_);
-        if (JdbcDebugCfg.entryActive) {
-            debug[methodId_SQLMXCallableStatement_LLIJL].methodEntry();
-            debug[methodId_SQLMXCallableStatement_LLIJL].methodExit();
-        }
-    }
-
     // native methods
     native void prepareCall(String server, long dialogueId, int txid,
             boolean autoCommit, int txnMode, String stmtLabel, String sql,
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClob.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClob.java
index 1d9f03b..379f8e3 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClob.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClob.java
@@ -35,6 +35,7 @@
 import java.io.IOException;
 import java.util.Date;
 import java.io.PrintWriter;
+import java.io.StringReader;
 
 public class SQLMXClob extends SQLMXLob implements Clob 
 {
@@ -72,7 +73,6 @@
 		if (JdbcDebugCfg.entryActive) debug[methodId_getCharacterStream].methodEntry();
 		try
 		{
-			checkIfCurrent();
 			// Close the reader and inputStream hander over earlier
 			if (reader_ != null)
 			{
@@ -113,6 +113,7 @@
 
 	public String getSubString(long pos, int length) throws SQLException
 	{
+/*
 		if (JdbcDebugCfg.entryActive) debug[methodId_getSubString].methodEntry();
 		try
 		{
@@ -150,8 +151,6 @@
 			offset = (int)((pos-1) % chunkSize_);
 			retString = new StringBuffer(length);
 		
-			prepareGetLobDataStmt();
-
 			if ((traceWriter_ != null) && 
 				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
 			{
@@ -203,6 +202,8 @@
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_getSubString].methodExit();
 		}
+*/
+		return null;
 	}
 
 	public long position(Clob searchstr, long start) throws SQLException
@@ -230,6 +231,7 @@
 
 	public long position(String searchstr, long start) throws SQLException
 	{
+/*
 		if (JdbcDebugCfg.entryActive) debug[methodId_position_LJ_str].methodEntry();
 		try
 		{
@@ -242,7 +244,6 @@
 				messageArguments[0] = "Clob.position(String, long)";
 				throw Messages.createSQLException(conn_.locale_,"invalid_input_value", messageArguments);
 			}
-			checkIfCurrent();
 			clobData = getSubString(start, (int)length());
 			retValue = clobData.indexOf(searchstr);
 			if (retValue != -1)
@@ -254,6 +255,8 @@
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_position_LJ_str].methodExit();
 		}
+*/
+		return 0;
 	}
 
 	public OutputStream setAsciiStream(long pos) throws SQLException
@@ -261,8 +264,6 @@
 		if (JdbcDebugCfg.entryActive) debug[methodId_setAsciiStream].methodEntry();
 		try
 		{
-			// Check if Autocommit is set, and no external transaction exists
-			checkAutoCommitExtTxn();
 			checkIfCurrent();
 			// Close the writer and OutputStream hander over earlier
 			if (writer_ != null)
@@ -339,8 +340,7 @@
 		if (JdbcDebugCfg.entryActive) debug[methodId_setString_JL].methodEntry();
 		try
 		{
-			if (str == null)
-			{
+			if (str == null || pos > 1) {
 				Object[] messageArguments = new Object[1];
 				messageArguments[0] = "Clob.setString(long, String)";
 				throw Messages.createSQLException(conn_.locale_,"invalid_input_value", messageArguments);
@@ -358,139 +358,21 @@
 		if (JdbcDebugCfg.entryActive) debug[methodId_setString_JLII].methodEntry();
 		try
 		{
-			int endChunkNo;
-			int updOffset;
-			int updLen;
-			int	chunkNo;
-			long lobLenForUpd;
-			int	 strOffset;
-			int retLen;
-			int totalRetLen;
-			int copyLen;
-			long remLen;
-			long lobLen;
-
-			if (str == null || pos <= 0 || len < 0 || offset < 0)
-			{
+			checkIfCurrent();
+			if (str == null || pos > 1  || len < 0 || offset < 0) {
 				Object[] messageArguments = new Object[1];
-				messageArguments[0] = "Clob.setString(long, String, int, int)";
+				messageArguments[0] = "Clob.setString(long, String)";
 				throw Messages.createSQLException(conn_.locale_,"invalid_input_value", messageArguments);
 			}
-			checkIfCurrent();
-			lobLen = length();
-			if (pos > lobLen+1)
-				throw Messages.createSQLException(conn_.locale_,"invalid_position_value", null);
-			copyLen = len;
-			remLen = pos-1+len; // Length that needs to be either updated or inserted
-			strOffset = offset;
-			totalRetLen = 0;
-			chunkNo = (int)((pos-1)/ chunkSize_);	// Starting chunkNo
-
-			// Calculate the length that can be updated rounded to chunk size
-			if ((lobLen % chunkSize_) == 0)
-				lobLenForUpd = (lobLen / chunkSize_) * chunkSize_;
-			else
-				lobLenForUpd = ((lobLen / chunkSize_)+1) * chunkSize_; // LOB data offset to the first char of the NEXT chunk insertion
-			     
-			if (remLen <= lobLenForUpd)
-				updLen	= len;
-			else
-				updLen = (int)(lobLenForUpd - (pos-1));
-
-			if (updLen > 0)
-			{
-				updOffset = (int)((pos-1) % chunkSize_); // offset from the beginning of the chunk
-				prepareUpdLobDataStmt();
-
-				synchronized (conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT])
-				{
-					conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setString(4, tableName_);
-					conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setLong(5, dataLocator_);
-				
-					while (true)
-					{
-						conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setInt(6, chunkNo);
-						conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setInt(1, updOffset);
-						if ((updOffset + updLen) <= chunkSize_)
-						{
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setInt(3, updOffset + updLen + 1);
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setString(2, str.substring(strOffset, strOffset+updLen));
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].executeUpdate();
-							totalRetLen += updLen;
-							strOffset += updLen;
-							chunkNo++;
-							break;
-						}
-						else
-						{
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setInt(3, chunkSize_+1);
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].setString(2, str.substring(strOffset, strOffset+chunkSize_-updOffset));
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT].executeUpdate();
-							totalRetLen += (chunkSize_-updOffset);
-							strOffset += (chunkSize_-updOffset);
-							updLen -= (chunkSize_-updOffset);
-							chunkNo++;
-						}
-						updOffset = 0;
-					}
-				}
-				copyLen = (int)(remLen - lobLenForUpd);
-
-				if ((traceWriter_ != null) && 
-					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-				{
-					traceWriter_.println(getTraceId() 
-						+ "setString(" + pos + ",<String>," + offset + "," + len 
-						+ ") - UpdLobDataStmt params: tableName_=" + tableName_ 
-						+ " dataLocator_=" + dataLocator_ + " chunkNo=" + chunkNo
-						+ " updOffset=" + updOffset + " updLen=" + updLen
-						+ " remLen=" + remLen + " lobLenForUpd=" + lobLenForUpd 
-						+ " strOffset=" + strOffset	+ " totalRetLen=" + totalRetLen);
-				}
+			ir_ = new StringReader(str);	
+			irLength_ = len;
+			try {
+				ir_.skip(offset);
+			} catch (IOException ioe) {
+				throw new SQLException(ioe);
 			}
-			if (remLen > lobLenForUpd)
-			{
-				while (true)
-				{
-					prepareInsLobDataStmt();
-
-					synchronized (conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT])
-					{
-						conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setString(1, tableName_);
-						conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setLong(2, dataLocator_);
-						conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setInt(3, chunkNo);
-						if (copyLen <= chunkSize_)
-						{
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setString(4, str.substring(strOffset, strOffset+copyLen));
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].executeUpdate();
-							strOffset += copyLen;
-							totalRetLen += copyLen;
-							break;
-						}
-						else
-						{
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setString(4, str.substring(strOffset, strOffset+chunkSize_));
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].executeUpdate();
-							strOffset += chunkSize_;
-							copyLen -= chunkSize_;
-							totalRetLen += chunkSize_;
-						}
-						chunkNo++;
-					}
-				}
-				
-				if ((traceWriter_ != null) && 
-					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-				{
-					traceWriter_.println(getTraceId() 
-						+ "setString(" + pos + ",<String>," + offset + "," + len 
-						+ ") - InsLobDataStmt params: tableName_=" + tableName_ 
-						+ " dataLocator_=" + dataLocator_ + " (total)chunkNo=" + chunkNo
-						+ " copyLen=" + copyLen + " strOffset=" + strOffset 
-						+ " totalRetLen=" + totalRetLen);
-				}
-			}
-			return totalRetLen;
+			populate();
+			return len-offset;   
 		}
 		finally
 		{
@@ -498,7 +380,7 @@
 		}
 	}
 
-	void close()
+	void close() throws SQLException 
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_close].methodEntry();
 		try
@@ -509,16 +391,17 @@
 					reader_.close();
 				if (writer_ != null)
 					writer_.close();
+				super.close();
 			}
 			catch (IOException e)
 			{
+				throw new SQLException(e);
 			}
 			finally
 			{
 				reader_ = null;
 				writer_ = null;
 			}
-			super.close();
 		}
 		finally
 		{
@@ -541,27 +424,22 @@
 			SQLMXLobOutputStream os;
 			SQLMXClobWriter cw;
 
+			if (inputLob_ != null) {
+				is_ = inputLob_.getAsciiStream();
+				ir_ = inputLob_.getCharacterStream();
+			}
+			else if (inputLobStr_ != null) {
+				ir_  = new StringReader(inputLobStr_);
+			}
 			if (is_ != null)
 			{
 				os = (SQLMXLobOutputStream)setOutputStream(1);
 				os.populate(is_, isLength_);
-				is_ = null;
 			}
 			else if (ir_ != null)
 			{
 				cw = (SQLMXClobWriter)setCharacterStream(1);
 				cw.populate(ir_, irLength_);
-				ir_ = null;
-			}
-			else if (inputLob_ != null)
-			{	
-				populateFromClob();
-				inputLob_ = null;			
-			}
-			else if (inputLobStr_ != null)
-			{
-				setString(1, inputLobStr_);
-				inputLobStr_ = null;
 			}
 		}
 		finally
@@ -570,341 +448,36 @@
 		}
 	}
 	
-	void populateFromClob() throws SQLException
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_populateFromClob].methodEntry();
-		try
-		{
-			long		pos;
-			String		s;
-			int			ret;
-			ResultSet	rs;
-			SQLMXClob	inputClob;
-			int			chunkNo = 0;
-			
-			pos = 1;
-			if (inputLob_ instanceof SQLMXClob)
-			{
-				// When SQL/MX supports insert into a table by selecting some other rows in
-				// the same table, we should change the code to do so
-				// Until then, we read a row and write to the same table with different
-				// data locator till all the rows are read 
-				inputClob = (SQLMXClob)inputLob_;
-
-				prepareGetLobDataStmt();
-				prepareInsLobDataStmt();
-
-				if ((traceWriter_ != null) && 
-					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-				{
-					traceWriter_.println(getTraceId() 
-						+ "populateFromClob() - GetLobDataStmt params: tableName_=" + inputClob.tableName_ 
-						+ " dataLocator_=" + inputClob.dataLocator_ + " chunkNo=0"
-						+ " Integer.MAX_VALUE=" + Integer.MAX_VALUE);
-				}
-
-				synchronized (conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_DATA_STMT])
-				{
-					conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_DATA_STMT].setString(1, inputClob.tableName_);
-					conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_DATA_STMT].setLong(2, inputClob.dataLocator_);
-					conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_DATA_STMT].setInt(3, 0);	// start ChunkNo
-					conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_DATA_STMT].setInt(4, Integer.MAX_VALUE);
-					rs = conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_DATA_STMT].executeQuery();
-					try 
-					{
-						synchronized(conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT])
-						{
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setString(1, tableName_);
-							conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setLong(2, dataLocator_);
-					
-							while (rs.next())
-							{
-								s = rs.getString(1);
-								conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setInt(3, chunkNo);
-								conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].setString(4, s);
-								conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT].executeUpdate();
-								chunkNo++;
-							}
-						}
-						
-						if ((traceWriter_ != null) && 
-							((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-						{
-							traceWriter_.println(getTraceId() 
-								+ "populateFromClob() - InsLobDataStmt params: tableName_=" + tableName_ 
-								+ " dataLocator_=" + dataLocator_ + " (total)chunkNo=" + chunkNo);
-						}
-					} 
-					finally 
-					{
-						rs.close();
-					}
-				}
-			}
-			else
-			{
-				while (true)
-				{
-					s = inputLob_.getSubString(pos, chunkSize_);
-					if (s.length() == 0)
-						break;
-					ret = setString(pos, s);
-					pos += s.length();
-				}
-			}
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_populateFromClob].methodExit();
-		}
-	}
-
-	// The following methods are used to prepare the LOB statement specific 
-	// to CLOB objects, and re-prepares if the lobTableName_ has changed. 
-	void prepareGetLobLenStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobLenStmt].methodEntry();
-		try
-		{
-			conn_.prepareGetLobLenStmt(lobTableName_,false);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobLenStmt].methodExit();
-		}
-	}
-	
-	void prepareDelLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareDelLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareDelLobDataStmt(lobTableName_,false);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareDelLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareGetLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareGetLobDataStmt(lobTableName_,false);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareGetLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareUpdLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareUpdLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareUpdLobDataStmt(lobTableName_,false);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareUpdLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareInsLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareInsLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareInsLobDataStmt(lobTableName_,false);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareInsLobDataStmt].methodExit();
-		}
-	}
-	
-	void prepareTrunLobDataStmt() throws SQLException 
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_prepareTrunLobDataStmt].methodEntry();
-		try
-		{
-			conn_.prepareTrunLobDataStmt(lobTableName_,false);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_prepareTrunLobDataStmt].methodExit();
-		}
-	}
-
-	// The following methods are used to return the CLOB prepared statement 
-	// from the connection object PS array for population and execution.
-	PreparedStatement getGetLobLenStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobLenStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_LEN_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobLenStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getDelLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getDelLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.CLOB_DEL_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getDelLobDataStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getTrunLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getTrunLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.CLOB_TRUN_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getTrunLobDataStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getInsLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getInsLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.CLOB_INS_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getInsLobDataStmt].methodExit();
-		}
-	}
-	
-	PreparedStatement getUpdLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getUpdLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.CLOB_UPD_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getUpdLobDataStmt].methodExit();
-		}
-	}
-
-	PreparedStatement getGetLobDataStmt()
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobDataStmt].methodEntry();
-		try
-		{
-			return conn_.LobPrepStmts[SQLMXConnection.CLOB_GET_LOB_DATA_STMT];
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_getGetLobDataStmt].methodExit();
-		}
-	}
-
 	// Constructors
-	SQLMXClob(SQLMXConnection connection, String tableName, long dataLocator) throws SQLException
+	SQLMXClob(SQLMXConnection connection, String lobLocator) throws SQLException
 	{
-		super(connection, tableName, dataLocator, connection.clobTableName_, false);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJ].methodEntry();
-		try
-		{
-			if (connection.clobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_clobTableName", null);
-
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJ].methodExit();
-		}
+		super(connection, lobLocator, false);
 	}
 
-	SQLMXClob(SQLMXConnection connection, String tableName, long dataLocator, InputStream x, 
-		int length) throws SQLException
+	SQLMXClob(SQLMXConnection connection, String lobLocator, InputStream x, long length) throws SQLException
 	{
-		super(connection, tableName, dataLocator, x, length, connection.clobTableName_, false);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJLI_stream].methodEntry();
-		try
-		{
-			if (connection.clobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_clobTableName", null);
-
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJLI_stream].methodExit();
-		}
+		super(connection, lobLocator, x, length, false);
 	}
 
-	SQLMXClob(SQLMXConnection connection, String tableName, long dataLocator, Reader x, 
-		int length) throws SQLException
+	SQLMXClob(SQLMXConnection connection, String lobLocator, Reader x, long length) throws SQLException
 	{
-		super(connection, tableName, dataLocator, connection.clobTableName_, false);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJLI_reader].methodEntry();
-		try
-		{
-			if (connection.clobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_clobTableName", null);
-			ir_ = x;
-			irLength_ = length;
-	
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJLI_reader].methodExit();
-		}
+		super(connection, lobLocator, false);
+		ir_ = x;
+		irLength_ = length;
 	}
 	
-	SQLMXClob(SQLMXConnection connection, String tableName, long dataLocator, Clob inputLob) throws SQLException
+	SQLMXClob(SQLMXConnection connection, String lobLocator, Clob inputLob) throws SQLException
 	{
-		super(connection, tableName, dataLocator, connection.clobTableName_, false);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJL_clob].methodEntry();
-		try
-		{
-			if (connection.clobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_clobTableName", null);
-			inputLob_ = inputLob;
-
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJL_clob].methodExit();
-		}
+		super(connection, lobLocator, false);
+		inputLob_ = inputLob;
 	}
 
-	SQLMXClob(SQLMXConnection connection, String tableName, long dataLocator, String lobStr) throws SQLException
+	SQLMXClob(SQLMXConnection connection, String lobLocator, String lobStr) throws SQLException
 	{
-		super(connection, tableName, dataLocator, connection.clobTableName_, false);
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJL_string].methodEntry();
-		try
-		{
-			if (connection.clobTableName_ == null)
-				throw Messages.createSQLException(conn_.locale_,"no_clobTableName", null);
-			inputLobStr_ = lobStr;
-
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClob_LLJL_string].methodExit();
-		}
+		super(connection, lobLocator, false);
+		inputLobStr_ = lobStr;
 	}
+
 	public void setTraceId(String traceId_) {
 		this.traceId_ = traceId_;
 	}
@@ -927,15 +500,17 @@
 	}
 
 	//fields
-	private String				traceId_;
+	private String		traceId_;
 	static PrintWriter	traceWriter_;
-	static int			traceFlag_;
+	static int		traceFlag_;
 	SQLMXClobReader		reader_;
 	SQLMXClobWriter		writer_;
-	Reader				ir_;
-	int					irLength_;
-	Clob				inputLob_;
-	String				inputLobStr_;
+	Reader			ir_;
+	long			irLength_;
+	Clob			inputLob_;
+	String			inputLobStr_;
+	long			startingPos_;	
+
 	private static int methodId_getAsciiStream			=  0;
 	private static int methodId_getCharacterStream		=  1;
 	private static int methodId_getSubString			=  2;
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobReader.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobReader.java
index 9d2e46d..f2ed8db 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobReader.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobReader.java
@@ -34,6 +34,7 @@
 import java.io.IOException;
 import java.util.Date;
 import java.io.PrintWriter;
+import java.nio.CharBuffer;
 
 public class SQLMXClobReader extends Reader
 {
@@ -83,12 +84,11 @@
 			if (isClosed_)
 				throw new IOException("Reader is in closed state");
 			if (currentChar_ == charsRead_)
-				retValue = readChunkThrowIO(null, 0, clob_.chunkSize_);
+				retValue = readChunkThrowIO();
 			if (retValue != -1)
 			{
-				retValue = chunk_[currentChar_];
-				if (currentChar_ != charsRead_)
-					currentChar_++;
+				retValue = chunk_.get();
+				currentChar_++;
 			}
 			return retValue;
 		}
@@ -118,50 +118,54 @@
 		int len)
 		throws IOException
 	{
+		return read(cbuf, off, len, false);
+	}
+
+	public int read(char[] cbuf,
+		int off,
+		int len,
+		boolean skip)
+		throws IOException
+	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_read_CII].methodEntry();
 		try
 		{
-			int readLen;
+			int remainLen;
 			int copyLen;
 			int copyOffset;
-			int tempLen = 0;
-			int rowsToRead;
 			int retLen;
+			int availableLen;
+			int copiedLen = 0;
 
 			if (isClosed_)
 				throw new IOException("Reader is in closed state");
 			if (cbuf == null)
 				throw new IOException("Invalid input value");
-			copyLen = len;
+                        if (eor_)
+				throw new IOException("End of Reader already reached");
+			remainLen = len;
 			copyOffset = off;
-			readLen = 0;
-			if (currentChar_ < charsRead_)
-			{
-				if (copyLen+currentChar_ <= charsRead_)
-				{
-					System.arraycopy(chunk_, currentChar_, cbuf, copyOffset, copyLen);
-					currentChar_ += copyLen;
-					readLen = copyLen;
-					return readLen;
-				}
+			while (remainLen > 0) {
+				availableLen = charsRead_ - currentChar_;
+				if (availableLen > remainLen)	
+					copyLen = remainLen;
 				else
-				{
-					tempLen = charsRead_- currentChar_;
-					System.arraycopy(chunk_, currentChar_, cbuf, copyOffset, tempLen);
-					copyOffset += tempLen;
-					copyLen -= tempLen;
-					currentChar_ += tempLen;
+					copyLen = availableLen;
+				if (copyLen > 0) { 
+					if (! skip) 
+						System.arraycopy(chunk_, currentChar_, cbuf, copyOffset, copyLen);
+					currentChar_ += copyLen;
+					copyOffset += copyLen;
+					copiedLen += copyLen;
+					remainLen -= copyLen;
+				}
+				if (remainLen > 0) {
+					retLen = readChunkThrowIO();
+					if (retLen == -1)
+						break;
 				}
 			}
-			readLen = readChunkThrowIO(cbuf, copyOffset, copyLen);
-			if (readLen != -1)
-				retLen = readLen + tempLen;
-			else
-				retLen = tempLen;
-			if (retLen == 0)
-				return -1;
-			else
-				return retLen;
+			return copiedLen;
 		}
 		finally
 		{
@@ -178,8 +182,8 @@
 			if (isClosed_)
 				throw new IOException("Reader is in closed state");
 			currentChar_ = 0;
-			currentChunkNo_ = 0;
 			charsRead_ = 0;
+			eor_ = false;
 			return;
 		}
 		finally
@@ -191,210 +195,59 @@
 	public long skip(long n)
 		throws IOException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_skip].methodEntry();
-		try
-		{
-			long charsToSkip;
-			int noOfChunks = 0;
-			int remChars;
-			long retLen = 0;
-			long charsSkipped = 0;
-			int oldChunkNo;
-			int readLen;
-
-			if (isClosed_)
-				throw new IOException("Reader is in closed state");
-			if (n <= 0)
-				return 0;
-			if (currentChar_ + n > charsRead_)
-			{
-				charsSkipped = charsRead_ - currentChar_;
-				charsToSkip = n - charsSkipped;
-				currentChar_ += charsSkipped;
-			}
+		long totalSkippedLen = 0;
+		long skipRemain = n;
+		int skipLen;
+		int skippedLen;
+		while (skipRemain > 0) {
+			if (skipRemain <= Integer.MAX_VALUE)
+				skipLen = (int)skipRemain;
 			else
-			{
-				currentChar_ += n;
-				return n;
-			}
-			noOfChunks += (int)((charsToSkip-1) / clob_.chunkSize_);
-			if ((charsToSkip % clob_.chunkSize_) == 0)
-				remChars = clob_.chunkSize_;
-			else
-				remChars = (int)(charsToSkip % clob_.chunkSize_);
-			oldChunkNo = currentChunkNo_;	// Which is already 1 more
-			currentChunkNo_ = currentChunkNo_ + noOfChunks;
-			retLen = readChunkThrowIO(null, 0, clob_.chunkSize_);
-			if (retLen != -1)
-			{
-				charsSkipped += (currentChunkNo_ - oldChunkNo -1) * clob_.chunkSize_;
-				if (retLen < remChars)
-					remChars= (int)retLen;
-				currentChar_ = remChars;
-				charsSkipped += remChars;
-			}
-			else
-			{
-				if (currentChunkNo_ > 0)
-					readLen = ((currentChunkNo_-1) * clob_.chunkSize_) + currentChar_;
-				else
-					readLen = currentChar_;
-				try
-				{
-					charsSkipped = charsSkipped + clob_.length() - readLen;
-				}
-				catch (SQLException e)
-				{
-					throw new IOException(SQLMXLob.convSQLExceptionToIO(e));
-				}
-				// Exclude the bytes that are in chunk already
-				remChars = (int)(charsSkipped - (charsRead_ - currentChar_));
-				noOfChunks += (int)((remChars-1) / clob_.chunkSize_);
-				currentChunkNo_ = oldChunkNo + noOfChunks;
-				//calculate the bytes in the chunk and set currentChar and charsRead
-				//to reach EOD
-				if (remChars == 0)
-				{
-					currentChar_ = 0;
-					charsRead_ = 0;
-				}
-				else
-				{
-					if ((remChars % clob_.chunkSize_) == 0)
-						currentChar_ = clob_.chunkSize_;
-					else
-						currentChar_ = (int)(remChars % clob_.chunkSize_);
-					charsRead_ = currentChar_;
-				}
-			}
-			return charsSkipped;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_skip].methodExit();
-		}
+				skipLen = Integer.MAX_VALUE;	
+			skippedLen = read(null, 0, skipLen, true); 
+			if (skippedLen == -1)
+				break;
+			skipRemain -= skippedLen;
+			totalSkippedLen += skippedLen;
+		}	
+		return totalSkippedLen;
 	}
 
-	int readChunkThrowIO(char[] c, int off, int len) throws IOException
+	int readChunkThrowIO() throws IOException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_readChunkThrowIO].methodEntry();
-		try
-		{
-			int readLen;
-
-			try
-			{
-				readLen = readChunk(c, off, len);
-			}
-			catch (SQLException e)
-			{
-				throw new IOException(SQLMXLob.convSQLExceptionToIO(e));
-			}
-			return readLen;
+		int readLen;
+		try {
+			readLen = readChunk();
 		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_readChunkThrowIO].methodExit();
+		catch (SQLException e) {
+			throw new IOException(SQLMXLob.convSQLExceptionToIO(e));
 		}
+		return readLen;
 	}
 
-	int readChunk(char[] c, int off, int len) throws SQLException
+	int readChunk() throws SQLException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_readChunk].methodEntry();
-		try
-		{
-			int rowsToRead;
-			String	data;
-			int copyLen;
-			int	copyOffset;
-			int readLen = 0;
-			int dataLen;
-
-			rowsToRead = (len-1)/clob_.chunkSize_;
-			clob_.prepareGetLobDataStmt();
-			PreparedStatement GetClobDataStmt = clob_.getGetLobDataStmt();
-
-			if ((traceWriter_ != null) && 
-				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-			{
-				traceWriter_.println(getTraceId() 
-					+ "readChunk(<char>," + off + "," + len + ") - GetLobDataStmt params: tableName_=" + clob_.tableName_ 
-					+ " dataLocator_=" + clob_.dataLocator_
-					+ " currentChunkNo_=" + currentChunkNo_
-					+ " currentChunkNo_+rowsToRead=" + (currentChunkNo_+rowsToRead));
-			}
-
-			synchronized (GetClobDataStmt)
-			{
-				GetClobDataStmt.setString(1, clob_.tableName_);
-				GetClobDataStmt.setLong(2, clob_.dataLocator_);
-				GetClobDataStmt.setInt(3, currentChunkNo_);
-				GetClobDataStmt.setInt(4, currentChunkNo_+rowsToRead);
-				ResultSet rs = GetClobDataStmt.executeQuery();
-				copyLen = len;
-				copyOffset = off;
-				try 
-				{
-					while (rs.next())
-					{
-						data = rs.getString(1);
-						currentChunkNo_++;
-						charsRead_ = data.length();
-						dataLen = charsRead_;
-						if (c == null)
-						{
-							data.getChars(0, dataLen, chunk_, 0);
-							readLen += dataLen;
-							currentChar_ = 0;
-							break;
-						}
-						else
-						{
-							if (copyLen >= dataLen)
-							{
-								data.getChars(0, dataLen, c, copyOffset);
-								copyLen -= dataLen;
-								readLen += dataLen;
-								copyOffset += dataLen;
-								currentChar_ = dataLen;
-							} 
-							else
-							{
-								data.getChars(0, copyLen, c, copyOffset);
-								// copy the rest of data to chunk
-								data.getChars(copyLen, dataLen,  chunk_, copyLen);
-								readLen += copyLen;
-								currentChar_ = copyLen;
-								break;
-							}
-						}
-					}
-				} 
-				finally 
-				{
-					rs.close();
-				}
-			}
-			
-			if ((traceWriter_ != null) && 
-				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-			{
-				traceWriter_.println(getTraceId() 
-					+ "readChunk(<char>," + off + "," + len + ") - LOB data read: charsRead_=" + charsRead_ 
-					+ " readLen=" + readLen + " copyLen=" + copyLen + " currentChunkNo_=" + currentChunkNo_);
-			}
-
-			if (readLen == 0)
-				return -1;
-			else
-				return readLen;
+		int extractMode = 1; // get the lob data
+		chunk_.clear(); 
+		if (eor_)
+			return -1;
+		if (charsRead_ != 0 && (charsRead_ < clob_.chunkSize_)) {
+			eor_ = true;
+			extractMode = 2; // Close the extract
 		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_readChunk].methodExit();
+		charsRead_ = readChunk(conn_.server_, conn_.getDialogueId(), conn_.getTxid(), extractMode, clob_.lobLocator_, chunk_); 
+		if (charsRead_ == -1) {
+			extractMode = 2; // close the extract
+		 	readChunk(conn_.server_, conn_.getDialogueId(), conn_.getTxid(), extractMode, clob_.lobLocator_, chunk_); 
+			eor_ = true;
 		}
+                else
+			chunk_.limit(charsRead_);
+		return charsRead_;
 	}
 
+        native int readChunk(String server, long dialogueId, long txid,  long extractMode, String lobLocator, CharBuffer buffer);
+
 	// constructors
 	SQLMXClobReader(SQLMXConnection connection, SQLMXClob clob)
 	{
@@ -403,17 +256,19 @@
 		{
 			clob_ = clob;
 			conn_ = connection;
-			chunk_ = new char[clob_.chunkSize_];
-
+			chunk_ = CharBuffer.allocate(clob_.chunkSize_);
+			currentChar_ = 0;
+			charsRead_ = 0;
+			eor_ = false;
+			isClosed_ = false;
 			traceWriter_ = SQLMXDataSource.traceWriter_;
-			
-			
 		}
 		finally
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXClobReader].methodExit();
 		}
 	}
+
 	public void setTraceId(String traceId_) {
 		this.traceId_ = traceId_;
 	}
@@ -434,16 +289,17 @@
 	}
 
 	// Fields 
-	private String				traceId_;
+	private String		traceId_;
 	static PrintWriter	traceWriter_;
-	static int			traceFlag_;
-	SQLMXClob			clob_;
+	static int		traceFlag_;
+	SQLMXClob		clob_;
 	SQLMXConnection		conn_;
-	boolean				isClosed_;
-	char[]				chunk_;
-	int					currentChar_;
-	int					currentChunkNo_;
-	int					charsRead_;
+	boolean			isClosed_;
+	CharBuffer		chunk_;
+	int			currentChar_;
+	int			charsRead_;
+	boolean			eor_;
+	
 
 	private static int methodId_close				=  0;
 	private static int methodId_mark				=  1;
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobWriter.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobWriter.java
index a489c3e..410159d 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobWriter.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXClobWriter.java
@@ -64,7 +64,8 @@
 				throw new IOException("Output stream is in closed state");
 			if (! isFlushed_)
 			{
-				writeChunkThrowIO(null);
+				writeChunkThrowIO(chunk_, 0, currentChar_);
+				currentChar_ = 0;
 			}
 		}
 		finally
@@ -106,33 +107,25 @@
 					"length or offset is less than 0 or offset is greater than the length of array");
 			srcOffset = off;
 			copyLen = len;
-			while (true)
-			{
-				if (copyLen+currentChar_ < (clob_.chunkSize_))
-				{
+			while (true) {
+				if ((copyLen+currentChar_) < (clob_.chunkSize_)) {
 					System.arraycopy(cbuf, srcOffset, chunk_, currentChar_, copyLen);
 					currentChar_ += copyLen;
 					isFlushed_ = false;
 					break;
-				}
-				else
-				{
-					if (currentChar_ != 0)
-					{
+				} else {
+					if (currentChar_ != 0) {
 						tempLen = clob_.chunkSize_-currentChar_;
 						System.arraycopy(cbuf, srcOffset, chunk_, currentChar_, tempLen);
 						currentChar_ += tempLen;
-						writeChunkThrowIO(null);
-					}
-					else
-					{
+						writeChunkThrowIO(chunk_, 0, currentChar_);
+						currentChar_ = 0;
+					} else {
 						tempLen = clob_.chunkSize_;
-						currentChar_ += tempLen;
-						writeChunkThrowIO(new String(cbuf, srcOffset, tempLen));
+						writeChunkThrowIO(cbuf, srcOffset, tempLen);
 					}
 					copyLen -= tempLen;
 					srcOffset += tempLen;
-					currentChar_ = 0;
 				}
 			}
 		}
@@ -152,8 +145,10 @@
 			chunk_[currentChar_] = (char)c;
 			isFlushed_ = false;
 			currentChar_++;
-			if (currentChar_ == clob_.chunkSize_)
-				writeChunkThrowIO(null);
+			if (currentChar_ == clob_.chunkSize_) {
+				writeChunkThrowIO(chunk_, 0, currentChar_);
+				currentChar_ = 0;
+			}
 		}
 		finally
 		{
@@ -181,45 +176,40 @@
 		if (JdbcDebugCfg.entryActive) debug[methodId_write_LII].methodEntry();
 		try
 		{
+			int copyLen;
+			int srcOffset;
 			int tempLen;
-			int writeLen;
-			int srcOff;
-
-			writeLen = len;
-			srcOff = off;
 
 			if (isClosed_)
-				throw new IOException("Writer is in closed state");
+				throw new IOException("Output stream is in closed state");
 			if (str == null)
 				throw new IOException("Invalid input value");
-			if (currentChar_ != 0)
-			{
-				tempLen = clob_.chunkSize_ - currentChar_;
-				if (writeLen > tempLen)
-				{		
-					char[] cbuf = new char[tempLen];
-					str.getChars(srcOff, srcOff+tempLen, cbuf, 0);
-					write(cbuf, 0, cbuf.length);
-					writeLen -= tempLen;
-					srcOff += tempLen;
-				}
-			}
-			while (writeLen > 0)
-			{
-				if (writeLen < clob_.chunkSize_)
+			if (off < 0 || len < 0 || off > str.length())
+				throw new IndexOutOfBoundsException(
+					"length or offset is less than 0 or offset is greater than the length of array");
+			srcOffset = off;
+			copyLen = len;
+			while (true) {
+				if ((copyLen+currentChar_) < clob_.chunkSize_) {
+					System.arraycopy(str, srcOffset, chunk_, currentChar_, copyLen);
+					currentChar_ += copyLen;
+					isFlushed_ = false;
 					break;
-				else
-				{
-					writeChunkThrowIO(str.substring(srcOff, srcOff+clob_.chunkSize_));
-					writeLen -= clob_.chunkSize_;
-					srcOff += clob_.chunkSize_;
+				} else {
+					if (currentChar_ != 0) {
+						tempLen = clob_.chunkSize_-currentChar_;		
+						System.arraycopy(str, srcOffset, chunk_, currentChar_, tempLen);
+						currentChar_ += tempLen;
+						writeChunkThrowIO(chunk_, 0, currentChar_);
+						currentChar_ = 0;
+					} else {
+						tempLen = clob_.chunkSize_;
+						writeChunkThrowIO(str.toCharArray(), srcOffset, tempLen);
+					}	
+					copyLen -= tempLen;
+					srcOffset += tempLen;
 				}
-			}
-			if (writeLen != 0)
-			{
-				char[] cbuf = new char[writeLen];
-				str.getChars(srcOff, srcOff+writeLen, cbuf, 0);
-				write(cbuf, 0, cbuf.length);
+				
 			}
 		}
 		finally
@@ -228,82 +218,14 @@
 		}
 	}
 
-	void writeChunk(String str) throws SQLException
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_writeChunk].methodEntry();
-		try
-		{
-			String tempStr;
-	
-			if (currentChunkNo_ > updChunkNo_)
-			{
-				clob_.prepareInsLobDataStmt();
-				PreparedStatement InsClobDataStmt = clob_.getInsLobDataStmt();
-
-				synchronized (InsClobDataStmt)
-				{
-					InsClobDataStmt.setString(1, clob_.tableName_);
-					InsClobDataStmt.setLong(2, clob_.dataLocator_);
-					InsClobDataStmt.setInt(3, currentChunkNo_);
-					if (str == null)
-					{
-						if (currentChar_ != clob_.chunkSize_)
-							tempStr = new String(chunk_, 0, currentChar_);
-						else
-							tempStr = new String(chunk_);	
-					}
-					else
-						tempStr = str;
-					InsClobDataStmt.setString(4, tempStr);
-					InsClobDataStmt.executeUpdate();
-					currentChunkNo_++;
-					currentChar_ = 0;
-				}
-			}
-			else
-			{
-				clob_.prepareUpdLobDataStmt();
-				PreparedStatement UpdClobDataStmt = clob_.getUpdLobDataStmt();
-
-				synchronized (UpdClobDataStmt)
-				{
-					UpdClobDataStmt.setString(4, clob_.tableName_);
-					UpdClobDataStmt.setLong(5, clob_.dataLocator_);
-					UpdClobDataStmt.setInt(6, currentChunkNo_);
-					UpdClobDataStmt.setInt(1, updOffset_);
-					if (str == null)
-					{
-						if (updOffset_ != 0 || currentChar_ != clob_.chunkSize_)
-							tempStr = new String(chunk_, updOffset_, currentChar_-updOffset_);
-						else
-							tempStr = new String(chunk_);	
-					}
-					else
-						tempStr = str;		
-					UpdClobDataStmt.setInt(3, currentChar_+1);
-					UpdClobDataStmt.setString(2, tempStr);
-					UpdClobDataStmt.executeUpdate();
-					currentChunkNo_++;
-					currentChar_ = 0;
-					updOffset_ = 0;
-				}
-			}
-			isFlushed_ = true;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_writeChunk].methodExit();
-		}
-	}
-
-	void writeChunkThrowIO(String str) throws IOException
+	void writeChunkThrowIO(char[] chunk, int offset, int len) throws IOException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_writeChunkThrowIO].methodEntry();
 		try
 		{
 			try
 			{
-				writeChunk(str);
+				writeChunk(chunk, offset, len);
 			}
 			catch (SQLException e)
 			{
@@ -315,14 +237,22 @@
 			if (JdbcDebugCfg.entryActive) debug[methodId_writeChunkThrowIO].methodExit();
 		}
 	}
+
+	void writeChunk(char[] chunk, int offset, int len) throws SQLException
+	{
+		writeChunk(conn_.server_, conn_.getDialogueId(), conn_.getTxid(),
+				clob_.lobLocator_, new String(chunk, offset, len), startingPos_-1+offset);
+ 	}
+
+	native void writeChunk(String server, long dialogueId, long txid, String lobLocator, String chunk, long pos);
 	
-	void populate(Reader ir, int length) throws SQLException
+	void populate(Reader ir, long length) throws SQLException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_populate].methodEntry();
 		try
 		{
 			int tempLen;
-			int readLen;
+			long readLen;
 			int retLen;
 				
 			readLen = length;
@@ -331,36 +261,15 @@
 				while (readLen > 0)
 				{
 					if (readLen <= clob_.chunkSize_)
-						tempLen = readLen;
+						tempLen = (int)readLen;
 					else
 						tempLen = clob_.chunkSize_;
 					retLen = ir.read(chunk_, 0, tempLen);
 					if (retLen == -1)
 						break;
 					currentChar_ = retLen;
-
-					if ((traceWriter_ != null) && 
-						((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-					{
-						// For tracing, only print the 1st and last LOB data chunk write info to limit 
-						// potential overflow of buffer for trace output.
-						if (readLen==length) 			// 1st writeChunk
-						{
-							traceWriter_.println(getTraceId() 
-								+ "populate() -  First writeChunk data: tableName_=" + clob_.tableName_
-								+ " dataLocator_=" + clob_.dataLocator_ + " length=" + length 
-								+ " currentChunkNo_=" + currentChunkNo_ + " updChunkNo_=" + updChunkNo_ + " retLen=" + retLen);
-						}
-						if (readLen<=clob_.chunkSize_)	// last writeChunk (NOTE: last chunk can be exactly chunkSize_)
-						{
-							traceWriter_.println(getTraceId() 
-								+ "populate() -  Last writeChunk data: tableName_=" + clob_.tableName_
-								+ " dataLocator_=" + clob_.dataLocator_ + " length=" + length 
-								+ " currentChunkNo_=" + currentChunkNo_ + " updChunkNo_=" + updChunkNo_ + " retLen=" + retLen);
-						}
-					}
-
-					writeChunk(null);
+					writeChunk(chunk_, 0, currentChar_);
+					currentChar_ = 0;
 					readLen -= retLen;
 				}
 			}
@@ -394,20 +303,7 @@
 			startingPos_ = pos;
 			chunk_ = new char[clob_.chunkSize_];
 			isFlushed_ = false;
-			if (length == 0)
-				updChunkNo_ = -1;
-			else
-			{
-				if ((length % clob_.chunkSize_) == 0)
-					updChunkNo_ = (int)(length / clob_.chunkSize_)-1;
-				else
-					updChunkNo_ = (int)(length / clob_.chunkSize_);
-			}
-			currentChunkNo_ = (int)((pos-1)/ clob_.chunkSize_);
-			currentChar_ = (int)((pos-1) % clob_.chunkSize_);
-			updOffset_ = (int)((pos-1) % clob_.chunkSize_);
-
-		
+			currentChar_ = 0;
 		}
 		finally
 		{
@@ -436,19 +332,16 @@
 	}
 
 	// Fields
-	private String				traceId_;
+	private String		traceId_;
 	static PrintWriter	traceWriter_;
-	static int			traceFlag_;
-	SQLMXClob			clob_;
-	long				startingPos_;
+	static int		traceFlag_;
+	SQLMXClob		clob_;
+	long			startingPos_;
 	SQLMXConnection		conn_;
-	boolean				isClosed_;
-	char[]				chunk_;
-	int					currentChar_;
-	int					currentChunkNo_;
-	boolean				isFlushed_;
-	int					updChunkNo_;
-	int					updOffset_;
+	boolean			isClosed_;
+	char[]			chunk_;
+	int			currentChar_;
+	boolean			isFlushed_;
 
 	private static int methodId_close				=  0;
 	private static int methodId_flush				=  1;
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java
index 0f0835d..e2961d3 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXConnection.java
@@ -229,7 +229,7 @@
             debug[methodId_commit].traceOut(JdbcDebug.debugLevelEntry,
                     "beginTransFlag_ = " + beginTransFlag_
                     + "; autoCommit_ = " + autoCommit_
-                    + "; txid_ = " + getTxid_());
+                    + "; txid_ = " + getTxid());
             if (JdbcDebugCfg.entryActive)
             debug[methodId_commit].methodExit();
         }
@@ -582,7 +582,7 @@
 
             if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
             printIdMapEntry(cstmt);
-            cstmt.prepareCall(server_, getDialogueId_(), getTxid_(),
+            cstmt.prepareCall(server_, getDialogueId(), getTxid(),
                     autoCommit_, transactionMode_, cstmt.getStmtLabel_(),
                     cstmt.sql_.trim(), cstmt.queryTimeout_,
                     cstmt.resultSetHoldability_, cstmt.fetchSize_);
@@ -666,7 +666,7 @@
             }
             if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
             printIdMapEntry(cstmt);
-            cstmt.prepareCall(server_, getDialogueId_(), getTxid_(),
+            cstmt.prepareCall(server_, getDialogueId(), getTxid(),
                     autoCommit_, transactionMode_, cstmt.getStmtLabel_(),
                     cstmt.sql_.trim(), cstmt.queryTimeout_,
                     cstmt.resultSetHoldability_, cstmt.fetchSize_);
@@ -757,7 +757,7 @@
 
             if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
             printIdMapEntry(cstmt);
-            cstmt.prepareCall(server_, getDialogueId_(), getTxid_(),
+            cstmt.prepareCall(server_, getDialogueId(), getTxid(),
                     autoCommit_, transactionMode_, cstmt.getStmtLabel_(),
                     cstmt.sql_.trim(), cstmt.queryTimeout_,
                     cstmt.resultSetHoldability_, cstmt.fetchSize_);
@@ -864,7 +864,7 @@
             if (this.t2props.getEnableMFC().equalsIgnoreCase("on") && this.t2props.getBatchBinding() ==0) {
 
                 synchronized (SQLMXConnection.lockForMFCPrep) {
-                    pstmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
+                    pstmt.cpqPrepareJNI(server_, getDialogueId(), getTxid(),
                             autoCommit_, transactionMode_, "", moduleVersion_,
                             moduleTimestamp_, pstmt.getStmtLabel_(),
                             pstmt.isSelect_, pstmt.queryTimeout_,
@@ -872,7 +872,7 @@
                             pstmt.fetchSize_, sql.trim(),getSqlStmtTypeForMFC(sql.trim()));
                 }
             } else {
-                pstmt.prepare(server_, getDialogueId_(), getTxid_(), autoCommit_,
+                pstmt.prepare(server_, getDialogueId(), getTxid(), autoCommit_,
                         pstmt.getStmtLabel_(), pstmt.sql_.trim(), pstmt.isSelect_,
                         pstmt.queryTimeout_, pstmt.resultSetHoldability_,
                         batchBindingSize_, pstmt.fetchSize_);
@@ -956,7 +956,7 @@
                 batchBindingSize_ = 0;
             }
 
-            stmt.prepare(server_, getDialogueId_(), getTxid_(), autoCommit_,
+            stmt.prepare(server_, getDialogueId(), getTxid(), autoCommit_,
                     stmt.getStmtLabel_(), stmt.sql_.trim(), stmt.isSelect_,
                     stmt.queryTimeout_, stmt.resultSetHoldability_,
                     batchBindingSize_, stmt.fetchSize_);
@@ -1113,7 +1113,7 @@
             if (this.t2props.getEnableMFC().equalsIgnoreCase("on") && this.t2props.getBatchBinding() ==0) {
 
                 synchronized (SQLMXConnection.lockForMFCPrep) {
-                    stmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
+                    stmt.cpqPrepareJNI(server_, getDialogueId(), getTxid(),
                             autoCommit_, transactionMode_, "", moduleVersion_,
                             moduleTimestamp_, stmt.getStmtLabel_(),
                             stmt.isSelect_, stmt.queryTimeout_,
@@ -1121,7 +1121,7 @@
                             stmt.fetchSize_, sql.trim(),getSqlStmtTypeForMFC(sql.trim()));
                 }
             } else {
-                stmt.prepare(server_, getDialogueId_(), getTxid_(),
+                stmt.prepare(server_, getDialogueId(), getTxid(),
                         autoCommit_, stmt.getStmtLabel_(), stmt.sql_.trim(),
                         stmt.isSelect_, stmt.queryTimeout_,
                         stmt.resultSetHoldability_, batchBindingSize_,
@@ -1231,7 +1231,7 @@
             if (this.t2props.getEnableMFC().equalsIgnoreCase("on") && this.t2props.getBatchBinding() ==0) {
 
                 synchronized (SQLMXConnection.lockForMFCPrep) {
-                    stmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
+                    stmt.cpqPrepareJNI(server_, getDialogueId(), getTxid(),
                             autoCommit_, transactionMode_, "", moduleVersion_,
                             moduleTimestamp_, stmt.getStmtLabel_(),
                             stmt.isSelect_, stmt.queryTimeout_,
@@ -1239,7 +1239,7 @@
                             stmt.fetchSize_, sql.trim(),getSqlStmtTypeForMFC(sql.trim()));
                 }
             } else {
-                stmt.prepare(server_, getDialogueId_(), getTxid_(),
+                stmt.prepare(server_, getDialogueId(), getTxid(),
                         autoCommit_, stmt.getStmtLabel_(), stmt.sql_.trim(),
                         stmt.isSelect_, stmt.queryTimeout_,
                         stmt.resultSetHoldability_, batchBindingSize_,
@@ -1377,7 +1377,7 @@
             debug[methodId_rollback_V].traceOut(JdbcDebug.debugLevelEntry,
                     "beginTransFlag_ = " + beginTransFlag_
                     + "; autoCommit_ = " + autoCommit_
-                    + "; txid_ = " + getTxid_());
+                    + "; txid_ = " + getTxid());
             if (JdbcDebugCfg.entryActive)
             debug[methodId_rollback_V].methodExit();
         }
@@ -1440,7 +1440,7 @@
                 if (autoCommit_ != autoCommit)
                 {
                     if (connectInitialized_)
-                    setAutoCommit(server_, getDialogueId_(), autoCommit);
+                    setAutoCommit(server_, getDialogueId(), autoCommit);
                     autoCommit_ = autoCommit;
                 }
             }
@@ -1466,7 +1466,7 @@
             throw Messages.createSQLException(locale_,
                     "invalid_connection", null);
             if (catalog != null) {
-                setCatalog(server_, getDialogueId_(), catalog);
+                setCatalog(server_, getDialogueId(), catalog);
                 if (!catalog.startsWith("\""))
                 catalog_ = catalog.toUpperCase();
                 else
@@ -1613,7 +1613,7 @@
                 case TRANSACTION_REPEATABLE_READ:
                 case TRANSACTION_SERIALIZABLE:
                 // Check if connection is open
-                setTransactionIsolation(server_, getDialogueId_(),
+                setTransactionIsolation(server_, getDialogueId(),
                         mapTxnIsolation(level));
                 transactionIsolation_ = level;
                 updateConnectionReusability(SQL_SET_TRANSACTION);
@@ -1648,98 +1648,6 @@
         }
     }
 
-    /*
-     * RFE: Connection synchronization cpqPrepareStatement() is now
-     * synchronized.
-     */
-    // Method to be used by SQLJ-O
-public synchronized PreparedStatement cpqPrepareStatement(
-            String moduleName, int moduleVersion, long moduleTimestamp,
-            String stmtName, boolean isSelect) throws SQLException {
-        if (out_ != null) {
-            out_.println(getTraceId() + "cpqPrepareStatement(\"" + moduleName
-                    + "\"," + moduleTimestamp + ", \"" + stmtName + "\", \""
-                    + isSelect + ")");
-        }
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_cpqPrepareStatement].methodEntry();
-        try {
-            SQLMXPreparedStatement pstmt;
-
-            if (isClosed_)
-            throw Messages.createSQLException(locale_,
-                    "invalid_connection", null);
-            gcStmts();
-            pstmt = new SQLMXPreparedStatement(this, moduleName, moduleVersion,
-                    moduleTimestamp, stmtName, isSelect, holdability_);
-            addElement(pstmt);
-
-            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
-            printIdMapEntry(pstmt);
-
-            pstmt.cpqPrepareJNI(server_, getDialogueId_(), getTxid_(),
-                    autoCommit_, transactionMode_, pstmt.moduleName_,
-                    pstmt.moduleVersion_, pstmt.moduleTimestamp_, pstmt
-                    .getStmtLabel_(), pstmt.isSelect_,
-                    pstmt.queryTimeout_, pstmt.resultSetHoldability_,
-                    batchBindingSize_, pstmt.fetchSize_, "",false);
-            if (out_ != null) {
-                out_.println(getTraceId() + "cpqPrepareStatement(\"" + moduleName
-                        + "\"," + moduleTimestamp + ", \"" + stmtName + "\", \""
-                        + isSelect + ") returns PreparedStatement ["
-                        + pstmt.getStmtLabel_() + "]");
-            }
-            if (out_ != null) {
-                return new TPreparedStatement(pstmt, out_);
-            }
-            return pstmt;
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_cpqPrepareStatement].methodExit();
-        }
-    }
-
-    // Method to be used by SQLJ-O
-public CallableStatement cpqPrepareCall(String moduleName,
-            int moduleVersion, long moduleTimestamp, String stmtName)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_cpqPrepareCall].methodEntry();
-        if (JdbcDebugCfg.traceActive)
-        debug[methodId_cpqPrepareCall].methodParameters("moduleName="
-                + moduleName + ", moduleVersion=" + moduleVersion
-                + ", moduleTimestamp=" + moduleTimestamp + ", stmtName="
-                + stmtName);
-        try {
-            SQLMXCallableStatement cstmt;
-
-            if (isClosed_)
-            throw Messages.createSQLException(locale_,
-                    "invalid_connection", null);
-            gcStmts();
-            cstmt = new SQLMXCallableStatement(this, moduleName, moduleVersion,
-                    moduleTimestamp, stmtName);
-            addElement(cstmt);
-
-            if (this.t2props.getEnableLog().equalsIgnoreCase("ON"))
-            printIdMapEntry(cstmt);
-
-            cstmt.cpqPrepareCall(server_, getDialogueId_(), getTxid_(),
-                    autoCommit_, transactionMode_, cstmt.moduleName_,
-                    cstmt.moduleVersion_, cstmt.moduleTimestamp_, cstmt
-                    .getStmtLabel_(), cstmt.queryTimeout_,
-                    cstmt.resultSetHoldability_, cstmt.fetchSize_);
-            return cstmt;
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_cpqPrepareCall].methodExit();
-        }
-    }
-
-    /*
-     * RFE: Connection synchronization begintransaction() is now synchronized.
-     */
-    // Method to be used by SQLJ-O
 public synchronized void begintransaction() throws SQLException {
         if (JdbcDebugCfg.entryActive)
         debug[methodId_begintransaction].methodEntry();
@@ -1749,11 +1657,11 @@
             if (isClosed_)
             throw Messages.createSQLException(locale_,
                     "invalid_connection", null);
-            if (getTxid_() != 0)
+            if (getTxid() != 0)
             throw Messages.createSQLException(locale_,
                     "invalid_transaction_state", null);
 
-            txid = beginTransaction(server_, getDialogueId_());
+            txid = beginTransaction(server_, getDialogueId());
             if (txid != 0) {
                 setTxid_(txid);
                 autoCommit_ = false;
@@ -1837,7 +1745,7 @@
                     if (stmtObject != null) {
                         stmtId = stmtObject.intValue();
                         try {
-                            SQLMXStatement.close(server_, getDialogueId_(),
+                            SQLMXStatement.close(server_, getDialogueId(),
                                     stmtId, true);
                         } catch (SQLException e) {
                         }finally {
@@ -1907,7 +1815,7 @@
                     .equalsIgnoreCase("ON");
                     // MFC added two more parameters
 
-                    connectInit(server_, getDialogueId_(), catalog_, schema_,
+                    connectInit(server_, getDialogueId(), catalog_, schema_,
                             mploc_, isReadOnly_, autoCommit_,
                             mapTxnIsolation(transactionIsolation_),
                             loginTimeout_, queryTimeout_, enableMFC_,
@@ -1916,7 +1824,7 @@
                     );
 
                     if (iso88591EncodingOverride_ != null)
-                    setCharsetEncodingOverride(server_, getDialogueId_(),
+                    setCharsetEncodingOverride(server_, getDialogueId(),
                             SQLMXDesc.SQLCHARSETCODE_ISO88591,
                             iso88591EncodingOverride_);
                 } catch (SQLException e) {
@@ -2019,8 +1927,8 @@
                          */
                         if (!listOfCachedPrepStmtIds.contains(stmtIds.get(i))) {
                             try {
-                                // getDialogueId_()
-                                SQLMXStatement.close(server_, getDialogueId_(),
+                                // getDialogueId()
+                                SQLMXStatement.close(server_, getDialogueId(),
                                         ((Long) stmtIds.get(i)).intValue(),
                                         true);
                             } catch (SQLException se) {
@@ -2066,7 +1974,7 @@
                     for (int i = 0; i < size; i++) {
                         try {
                             SQLMXStatement
-                            .close(server_, getDialogueId_(),
+                            .close(server_, getDialogueId(),
                                     ((Long) stmtIds.get(i))
                                     .longValue(), true);
                         } catch (SQLException se) {
@@ -2078,9 +1986,9 @@
                 }
                 // Need to logically close the statement
                 // Rollback the Transaction independent of autoCommit mode
-                if (getTxid_() != 0) {
+                if (getTxid() != 0) {
                     try {
-                        rollback(server_, getDialogueId_(), getTxid_());
+                        rollback(server_, getDialogueId(), getTxid());
                     } catch (SQLException se1) {
                     }
                     setTxid_(0);
@@ -2088,13 +1996,13 @@
                 if (this.setOfCQDs.isEmpty() == false) {
                     if (clearCQD1 == null && clearCQD2 == null
                             && clearCQD3 == null) {
-                        clearSetOfCQDs(this.getDialogueId_());
+                        clearSetOfCQDs(this.getDialogueId());
                         clearCQD2 = this
                         .prepareForResetCQDs("CONTROL TABLE * RESET");
-                        clearSetOfCQDs(this.getDialogueId_());
+                        clearSetOfCQDs(this.getDialogueId());
                         clearCQD3 = this
                         .prepareForResetCQDs("CONTROL QUERY SHAPE CUT");
-                        clearSetOfCQDs(this.getDialogueId_());
+                        clearSetOfCQDs(this.getDialogueId());
                         clearCQD1 = this
                         .prepareForResetCQDs("CONTROL QUERY DEFAULT * RESET");
 
@@ -2105,7 +2013,7 @@
                         clearCQD3.execute();
                     }
                     //native call to clear native cqd list
-                    clearSetOfCQDs(this.getDialogueId_());
+                    clearSetOfCQDs(this.getDialogueId());
                     this.setOfCQDs.clear();
                     //to reset all the CQDs required for T2 connection.
                     connectInitialized_ = false;
@@ -2118,7 +2026,7 @@
                     out_.println(getTraceId() +"close()"+" Connection Hard closed");
                     out_.println(getTraceId() + "close(hardClose="+hardClose +",sendEvents="+sendEvents+")");
                 }
-                if (getDialogueId_() == 0)
+                if (getDialogueId() == 0)
                 return;
                 // close all the statements
                 Set<WeakReference> ks1 = refToStmt_.keySet();
@@ -2143,9 +2051,9 @@
                 refToStmt_.clear();
                 // Need to logically close the statement
                 // Rollback the Transaction independent of autoCommit mode
-                if (getTxid_() != 0) {
+                if (getTxid() != 0) {
                     try {
-                        rollback(server_, getDialogueId_(), getTxid_());
+                        rollback(server_, getDialogueId(), getTxid());
                     } catch (SQLException se1) {
                     }
                     setTxid_(0);
@@ -2154,14 +2062,14 @@
                 clearPreparedStatementsAll();
                 // Close the connection
                 try {
-                    // getDialogueId_(),setDialogueId_()
-                    SQLMXConnection.close(server_, getDialogueId_());
+                    // getDialogueId(),setDialogueI_()
+                    SQLMXConnection.close(server_, getDialogueId());
                 }finally {
                     isClosed_ = true;
                     keyForMap=this.incrementAndGetkeyForMapCounter();
-                    mapOfClosedDialogs.put(keyForMap, getDialogueId_());
+                    mapOfClosedDialogs.put(keyForMap, getDialogueId());
 
-                    setDialogueId_(0);
+                    setDialogueId(0);
                     removeElement();
                 }
             }
@@ -2179,7 +2087,7 @@
         debug[methodId_reuse].methodEntry(JdbcDebug.debugLevelPooling);
         try {
             if (connReuseBitMap_ != 0) {
-                connectReuse(server_, getDialogueId_(), connReuseBitMap_,
+                connectReuse(server_, getDialogueId(), connReuseBitMap_,
                         dsCatalog_, dsSchema_, mploc_,
                         TRANSACTION_READ_COMMITTED);
                 // Reset all connection attribute values
@@ -2228,39 +2136,10 @@
             debug[methodId_updateConnectionReusability].methodExit();
         }
     }
-
-    long getDataLocator(String lobTableName, boolean isBlob)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_getDataLocator].methodEntry();
-        if (JdbcDebugCfg.traceActive)
-        debug[methodId_getDataLocator].methodParameters("lobTableName="
-                + lobTableName + ", isBlob=" + isBlob);
-        try {
-            SQLMXDataLocator dataLoc;
-
-            if (lobTableName == null) {
-                if (isBlob)
-                throw Messages.createSQLException(locale_,
-                        "no_blobTableName", null);
-                throw Messages.createSQLException(locale_, "no_clobTableName",
-                        null);
-            }
-            dataLoc = (SQLMXDataLocator) lobTableToDataLoc_.get(lobTableName);
-            if (dataLoc == null) {
-                dataLoc = new SQLMXDataLocator(this, lobTableName);
-                lobTableToDataLoc_.put(lobTableName, dataLoc);
-            }
-            return dataLoc.getDataLocator(this, isBlob);
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_getDataLocator].methodExit();
-        }
-    }
-
+    //
     // Extension method for WLS, this method gives the pooledConnection object
     // associated with the given connection object.
-public PooledConnection getPooledConnection() throws SQLException {
+    public PooledConnection getPooledConnection() throws SQLException {
         if (JdbcDebugCfg.entryActive)
         debug[methodId_getPooledConnection]
         .methodEntry(JdbcDebug.debugLevelPooling);
@@ -2340,123 +2219,6 @@
         }
     }
 
-    // The following methods ensure that the LOB statements are only prepared
-    // for the
-    // BLOB/CLOB specific PreparedStatement objects (to avoid constant
-    // re-prepares), and
-    // that they are only re-prepared if the appropriate BLOB/CLOB lobTableName_
-    // has changed.
-    void prepareGetLobLenStmt(String lobTableName, boolean isBlob)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_prepareGetLobLenStmt].methodEntry();
-        try {
-            if (isBlob
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[BLOB_GET_LOB_LEN_STMT]))) {
-                String lobLenSQL = "select sum(char_length(lob_data)) from "
-                + lobTableName
-                + " where table_name = ? and data_locator = ?";
-                LobPrepStmts[BLOB_GET_LOB_LEN_STMT] = prepareLobStatement(lobLenSQL);
-                LobPrepStmtTableName[BLOB_GET_LOB_LEN_STMT] = lobTableName;
-            } else if ((!isBlob)
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[CLOB_GET_LOB_LEN_STMT]))) {
-                String lobLenSQL = "select sum(char_length(lob_data)) from "
-                + lobTableName
-                + " where table_name = ? and data_locator = ?";
-                LobPrepStmts[CLOB_GET_LOB_LEN_STMT] = prepareLobStatement(lobLenSQL);
-                LobPrepStmtTableName[CLOB_GET_LOB_LEN_STMT] = lobTableName;
-            }
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_prepareGetLobLenStmt].methodExit();
-        }
-    }
-
-    void prepareDelLobDataStmt(String lobTableName, boolean isBlob)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_prepareDelLobDataStmt].methodEntry();
-        try {
-            if (isBlob
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[BLOB_DEL_LOB_DATA_STMT]))) {
-                String lobDelSQL = "delete from "
-                + lobTableName
-                + " where table_name = ? and data_locator = ? and chunk_no >= ? and chunk_no <= ?";
-                LobPrepStmts[BLOB_DEL_LOB_DATA_STMT] = prepareLobStatement(lobDelSQL);
-                LobPrepStmtTableName[BLOB_DEL_LOB_DATA_STMT] = lobTableName;
-            } else if ((!isBlob)
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[CLOB_DEL_LOB_DATA_STMT]))) {
-                String lobDelSQL = "delete from "
-                + lobTableName
-                + " where table_name = ? and data_locator = ? and chunk_no >= ? and chunk_no <= ?";
-                LobPrepStmts[CLOB_DEL_LOB_DATA_STMT] = prepareLobStatement(lobDelSQL);
-                LobPrepStmtTableName[CLOB_DEL_LOB_DATA_STMT] = lobTableName;
-            }
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_prepareDelLobDataStmt].methodExit();
-        }
-    }
-
-    void prepareGetLobDataStmt(String lobTableName, boolean isBlob)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_prepareGetLobDataStmt].methodEntry();
-        try {
-            if (isBlob
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[BLOB_GET_LOB_DATA_STMT]))) {
-                String lobGetSQL = "select lob_data from "
-                + lobTableName
-                + " where table_name = ? and data_locator = ? and chunk_no >= ? and chunk_no <= ?";
-                LobPrepStmts[BLOB_GET_LOB_DATA_STMT] = prepareLobStatement(lobGetSQL);
-                LobPrepStmtTableName[BLOB_GET_LOB_DATA_STMT] = lobTableName;
-            } else if ((!isBlob)
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[CLOB_GET_LOB_DATA_STMT]))) {
-                String lobGetSQL = "select lob_data from "
-                + lobTableName
-                + " where table_name = ? and data_locator = ? and chunk_no >= ? and chunk_no <= ?";
-                LobPrepStmts[CLOB_GET_LOB_DATA_STMT] = prepareLobStatement(lobGetSQL);
-                LobPrepStmtTableName[CLOB_GET_LOB_DATA_STMT] = lobTableName;
-            }
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_prepareGetLobDataStmt].methodExit();
-        }
-    }
-
-    void prepareUpdLobDataStmt(String lobTableName, boolean isBlob)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_prepareUpdLobDataStmt].methodEntry();
-        try {
-            if (isBlob
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[BLOB_UPD_LOB_DATA_STMT]))) {
-                String lobUpdSQL = "update "
-                + lobTableName
-                + " set lob_data = subString(lob_data, 1, ?) || cast (? as varchar(24000)) || substring(lob_data from ?) where table_name = ? and data_locator = ? and chunk_no = ?";
-                LobPrepStmts[BLOB_UPD_LOB_DATA_STMT] = prepareLobStatement(lobUpdSQL);
-                LobPrepStmtTableName[BLOB_UPD_LOB_DATA_STMT] = lobTableName;
-            } else if ((!isBlob)
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[CLOB_UPD_LOB_DATA_STMT]))) {
-                String lobUpdSQL = "update "
-                + lobTableName
-                + " set lob_data = subString(lob_data, 1, ?) || cast (? as varchar(24000)) || substring(lob_data from ?) where table_name = ? and data_locator = ? and chunk_no = ?";
-                LobPrepStmts[CLOB_UPD_LOB_DATA_STMT] = prepareLobStatement(lobUpdSQL);
-                LobPrepStmtTableName[CLOB_UPD_LOB_DATA_STMT] = lobTableName;
-            }
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_prepareUpdLobDataStmt].methodExit();
-        }
-    }
     synchronized PreparedStatement prepareForResetCQDs(String sql)
     throws SQLException {
         try {
@@ -2468,7 +2230,7 @@
             connectInit();
             gcStmts();
             pstmt = new SQLMXPreparedStatement(this, sql);
-            pstmt.prepare(server_, getDialogueId_(), getTxid_(), autoCommit_,
+            pstmt.prepare(server_, getDialogueId(), getTxid(), autoCommit_,
                     pstmt.getStmtLabel_(), pstmt.sql_.trim(), pstmt.isSelect_,
                     pstmt.queryTimeout_, pstmt.resultSetHoldability_,
                     batchBindingSize_, pstmt.fetchSize_);
@@ -2479,106 +2241,9 @@
         }
     }
 
-    void prepareInsLobDataStmt(String lobTableName, boolean isBlob)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_prepareInsLobDataStmt].methodEntry();
-        try {
-            if (isBlob
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[BLOB_INS_LOB_DATA_STMT]))) {
-                String lobInsSQL = "insert into "
-                + lobTableName
-                + " (table_name, data_locator, chunk_no, lob_data) values (?,?,?,?)";
-                LobPrepStmts[BLOB_INS_LOB_DATA_STMT] = prepareLobStatement(lobInsSQL);
-                LobPrepStmtTableName[BLOB_INS_LOB_DATA_STMT] = lobTableName;
-            } else if ((!isBlob)
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[CLOB_INS_LOB_DATA_STMT]))) {
-                String lobInsSQL = "insert into "
-                + lobTableName
-                + " (table_name, data_locator, chunk_no, lob_data) values (?,?,?,?)";
-                LobPrepStmts[CLOB_INS_LOB_DATA_STMT] = prepareLobStatement(lobInsSQL);
-                LobPrepStmtTableName[CLOB_INS_LOB_DATA_STMT] = lobTableName;
-            }
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_prepareInsLobDataStmt].methodExit();
-        }
-    }
-
-    void prepareTrunLobDataStmt(String lobTableName, boolean isBlob)
-    throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_prepareTrunLobDataStmt].methodEntry();
-        try {
-            if (isBlob
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[BLOB_TRUN_LOB_DATA_STMT]))) {
-                String lobTrunSQL = "update "
-                + lobTableName
-                + " set lob_data = substring(lob_data, 1, ?) where table_name = ? and data_locator = ? and chunk_no = ?";
-                LobPrepStmts[BLOB_TRUN_LOB_DATA_STMT] = prepareLobStatement(lobTrunSQL);
-                LobPrepStmtTableName[BLOB_TRUN_LOB_DATA_STMT] = lobTableName;
-            } else if ((!isBlob)
-                    && !(lobTableName
-                            .equals(LobPrepStmtTableName[CLOB_TRUN_LOB_DATA_STMT]))) {
-                String lobTrunSQL = "update "
-                + lobTableName
-                + " set lob_data = substring(lob_data, 1, ?) where table_name = ? and data_locator = ? and chunk_no = ?";
-                LobPrepStmts[CLOB_TRUN_LOB_DATA_STMT] = prepareLobStatement(lobTrunSQL);
-                LobPrepStmtTableName[CLOB_TRUN_LOB_DATA_STMT] = lobTableName;
-            }
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_prepareTrunLobDataStmt].methodExit();
-        }
-    }
-
-    boolean prepareGetStrtDataLocStmt(String lobTableName, boolean isBlob,
-            String ucs2) throws SQLException {
-        if (JdbcDebugCfg.entryActive)
-        debug[methodId_prepareGetStrtDataLocStmt].methodEntry();
-        try {
-            String lobGetStrtDataLocSQL;
-
-            if (isBlob
-                    && (!(lobTableName
-                                    .equals(LobPrepStmtTableName[BLOB_GET_STRT_DATA_LOC_STMT])) || LobPrepStmtTableName[BLOB_GET_STRT_DATA_LOC_STMT] == null)) {
-                lobGetStrtDataLocSQL = "select * from (update "
-                + lobTableName
-                + " set lob_data = cast(cast(cast(lob_data as largeint) + ? as largeint) as varchar(100)) where table_name = 'ZZDATA_LOCATOR' and data_locator = 0 and chunk_no = 0 return cast(old.lob_data as largeint)+1) as tab1";
-                LobPrepStmts[BLOB_GET_STRT_DATA_LOC_STMT] = prepareLobStatement(lobGetStrtDataLocSQL);
-                LobPrepStmtTableName[BLOB_GET_STRT_DATA_LOC_STMT] = lobTableName;
-                return true;
-            } else if ((!isBlob)
-                    && (!(lobTableName
-                                    .equals(LobPrepStmtTableName[CLOB_GET_STRT_DATA_LOC_STMT])) || LobPrepStmtTableName[CLOB_GET_STRT_DATA_LOC_STMT] == null)) {
-                if (ucs2.equals(UCS_STR)) // Unicode data
-                {
-                    lobGetStrtDataLocSQL = "select * from (update "
-                    + lobTableName
-                    + " set lob_data = cast(cast(cast(lob_data as largeint) + ? as largeint) as varchar(100) character set UCS2) where table_name = 'ZZDATA_LOCATOR' and data_locator = 0 and chunk_no = 0 return cast(old.lob_data as largeint)+1) as tab1";
-                } else // ISO data
-                {
-                    lobGetStrtDataLocSQL = "select * from (update "
-                    + lobTableName
-                    + " set lob_data = cast(cast(cast(lob_data as largeint) + ? as largeint) as varchar(100)) where table_name = 'ZZDATA_LOCATOR' and data_locator = 0 and chunk_no = 0 return cast(old.lob_data as largeint)+1) as tab1";
-                }
-                LobPrepStmts[CLOB_GET_STRT_DATA_LOC_STMT] = prepareLobStatement(lobGetStrtDataLocSQL);
-                LobPrepStmtTableName[CLOB_GET_STRT_DATA_LOC_STMT] = lobTableName;
-                return true;
-            }
-            return false;
-        }finally {
-            if (JdbcDebugCfg.entryActive)
-            debug[methodId_prepareGetStrtDataLocStmt].methodExit();
-        }
-    }
-
     // Log the JDBC SQL statement and the STMTID to the idMapFile if the
     // enableLog_ property is set.
-private void printIdMapEntry(SQLMXStatement stmt) {
+    private void printIdMapEntry(SQLMXStatement stmt) {
         SQLMXDataSource.prWriter_.println("["
                 + T2Driver.dateFormat.format(new java.util.Date()) + "] "
                 + stmt.getStmtLabel_() + " (" + stmt.sql_.trim() + ")\n");
@@ -2610,8 +2275,8 @@
 //
 //			connectionTimeout_ = 60;
 
-            setDialogueId_(connect(server_, uid_, pwd_));
-            if (getDialogueId_() == 0)
+            setDialogueId(connect(server_, uid_, pwd_));
+            if (getDialogueId() == 0)
             return;
             isClosed_ = false;
             byteSwap_ = false;
@@ -2658,13 +2323,13 @@
 
             initConnectionProps(t2props);
 
-            setDialogueId_(connect(server_, uid_, pwd_));
-            if (getDialogueId_() == 0)
+            setDialogueId(connect(server_, uid_, pwd_));
+            if (getDialogueId() == 0)
             return;
             isClosed_ = false;
             byteSwap_ = false;
 
-            setIsSpjRSFlag(getDialogueId_(), t2props.isSpjrsOn());
+            setIsSpjRSFlag(getDialogueId(), t2props.isSpjrsOn());
 
             refQ_ = new ReferenceQueue<SQLMXStatement>();
             refToStmt_ = new HashMap<WeakReference, Long>();
@@ -2707,8 +2372,8 @@
 
             initConnectionProps(t2props);
 
-            setDialogueId_(connect(server_, uid_, pwd_));
-            if (getDialogueId_() == 0)
+            setDialogueId(connect(server_, uid_, pwd_));
+            if (getDialogueId() == 0)
             return;
             isClosed_ = false;
             byteSwap_ = false;
@@ -2900,15 +2565,15 @@
 //		this.txIDPerThread.set(new Integer(txid_));
     }
 
-public int getTxid_() {
+public int getTxid() {
         return txid_;
 //		return this.txIDPerThread.get().intValue();
     }
 
-public void setDialogueId_(long dialogueId_) throws SQLException {
+public void setDialogueId(long dialogueId_) throws SQLException {
         this.dialogueId_ = dialogueId_;
     }
-public long getDialogueId_() throws SQLException {
+public long getDialogueId() throws SQLException {
         if(dialogueId_ != 0) {
             if(mapOfClosedDialogs.containsKey(this.keyForMap)) {
                 throw new SQLException(Long.toHexString(mapOfClosedDialogs.get(this.keyForMap)) + " Connection is already closed.");
@@ -2987,8 +2652,6 @@
         loginTimeout_ = info.getLoginTimeout();
         enableMFC_ = info.getEnableMFC();
         compiledModuleLocation_ = info.getCompiledModuleLocation();
-        blobTableName_ = info.getBlobTableName();
-        clobTableName_ = info.getClobTableName();
         contBatchOnError_ = info.getContBatchOnError();
         iso88591EncodingOverride_ = info.getIso88591EncodingOverride();
 
@@ -3075,19 +2738,7 @@
 public static final int SQL_SET_TRANSACTION_FLAG = 0x0001;
 
     // Fields
-    static int reserveDataLocator_;
-    static HashMap<String, SQLMXDataLocator> lobTableToDataLoc_;
     static long rsCount_;
-
-    PreparedStatement InsLobDataStmt_;
-    PreparedStatement GetLobDataStmt_;
-    PreparedStatement GetLobLenStmt_;
-    PreparedStatement DelLobDataStmt_;
-    PreparedStatement TrunLobDataStmt_;
-    PreparedStatement UpdLobDataStmt_;
-
-    String clobTableName_;
-    String blobTableName_;
     boolean beginTransFlag_ = false;
     String server_;
     String dsn_;
@@ -3150,16 +2801,6 @@
     // context
     int connReuseBitMap_;
 
-    // Array used to store lob table name used when LOB statements are prepared.
-    // If the table names differ from one call to the next, the stmt will
-    // be re-prepared, and the new LOB table name will be saved off.
-    // Initialized to false, one each for the BLOB/CLOB statements listed above.
-    String[] LobPrepStmtTableName = new String[14];
-
-    // Array used to store the LOB prepared statements, indexed by
-    // the statement type statics that follow.
-    PreparedStatement[] LobPrepStmts = new PreparedStatement[14];
-
     // Cache area for character set
     static String getCharsetEncodingCached_server;
     static long getCharsetEncodingCached_dialogueId;
@@ -3353,17 +2994,6 @@
                     "getCharsetEncodingCached");
         }
 
-        String reserveDataLocator = System
-        .getProperty("t2jdbc.reserveDataLocator");
-        if (reserveDataLocator != null) {
-            try {
-                reserveDataLocator_ = Integer.parseInt(reserveDataLocator);
-            } catch (NumberFormatException e) {
-            }
-        }
-        if (reserveDataLocator_ == 0)
-        reserveDataLocator_ = 100;
-        lobTableToDataLoc_ = new HashMap<String, SQLMXDataLocator>();
     }
     int dsBatchBindingSize_;
     int dsTransactionMode_;
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDataLocator.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDataLocator.java
deleted file mode 100644
index 487c436..0000000
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDataLocator.java
+++ /dev/null
@@ -1,368 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-/* -*-java-*-
- * Filename    : SQLMXDataLocator.java
- * Description : For each clobTableName or blobTableName property, an 
- *     instance of this object will be created.
- *
- */
-
-package org.apache.trafodion.jdbc.t2;
-
-import java.sql.*;
-//import com.tandem.tmf.*;		// Linux port - ToDo
-import java.util.Date;
-import java.io.PrintWriter;
-
-class SQLMXDataLocator {
-	synchronized long getDataLocator(SQLMXConnection conn, boolean isBlob)
-			throws SQLException {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_getDataLocator].methodEntry();
-		try {
-			isBlob_ = isBlob;
-			// This method is synchronized to ensure that the two different
-			// threads will not reserve
-			// data locator,
-			if (startDataLocator_ == 0
-					|| ((currentDataLocator_ - startDataLocator_ + 1) == SQLMXConnection.reserveDataLocator_))
-				currentDataLocator_ = getStartDataLocator(conn);
-			else
-				currentDataLocator_++;
-			return currentDataLocator_;
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_getDataLocator].methodExit();
-		}
-	}
-
-	long getStartDataLocator(SQLMXConnection conn) throws SQLException {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_getStartDataLocator].methodEntry();
-
-/* Linux port - ToDo tmf.jar related
-		try {
-			Current tx = null;
-			ControlRef cref = null;
-			boolean txBegin = false;
-			int currentTxid = conn.getTxid_();
-			conn.setTxid_(0);
-
-			try {
-				tx = new Current();
-				// Suspend the existing transaction, suspend returns null if
-				// there is none
-				cref = tx.suspend();
-				tx.begin();
-				txBegin = true;
-
-				synchronized (conn) {
-					prepareGetStrtDataLocStmt(conn);
-					GetStrtDataLoc_.setLong(1,
-							SQLMXConnection.reserveDataLocator_);
-
-					ResultSet rs = GetStrtDataLoc_.executeQuery();
-					try {
-						if (rs.next()) {
-							startDataLocator_ = rs.getLong(1);
-
-							if ((traceWriter_ != null)
-									&& ((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL))) {
-								traceWriter_
-										.println(getTraceId()
-												+ "getStartDataLocator() - GetStrtDataLocStmt params: reserveDataLocator_="
-												+ SQLMXConnection.reserveDataLocator_
-												+ " startDataLocator_="
-												+ startDataLocator_);
-							}
-						} else {
-							insertDataLocatorRow(conn);
-						}
-					} finally {
-						rs.close();
-					}
-					tx.commit(false);
-					txBegin = false;
-				}
-				if (cref != null)
-					tx.resume(cref);
-			}
-			catch (com.tandem.util.FSException fe1) {
-				SQLException se1 = null;
-				SQLException se2;
-
-				try {
-					if (txBegin)
-						tx.rollback();
-					if (cref != null)
-						tx.resume(cref);
-				} catch (com.tandem.util.FSException fe2) {
-					Object[] messageArguments = new Object[2];
-					messageArguments[0] = Short.toString(fe2.error);
-					messageArguments[1] = fe2.getMessage();
-					se1 = Messages.createSQLException(conn.locale_,
-							"transaction_error", messageArguments);
-				}
-				Object[] messageArguments = new Object[2];
-				messageArguments[0] = Short.toString(fe1.error);
-				messageArguments[1] = fe1.getMessage();
-				se2 = Messages.createSQLException(conn.locale_,
-						"transaction_error", messageArguments);
-				if (se1 != null)
-					se2.setNextException(se1);
-				throw se2;
-			}
-			catch (SQLException se) {
-				SQLException se1 = null;
-				try {
-					if (txBegin)
-						tx.rollback();
-					if (cref != null)
-						tx.resume(cref);
-				}
-				catch (com.tandem.util.FSException fe2) {
-					Object[] messageArguments = new Object[2];
-					messageArguments[0] = Short.toString(fe2.error);
-					messageArguments[1] = fe2.getMessage();
-					se1 = Messages.createSQLException(conn.locale_,
-							"transaction_error", messageArguments);
-				}
-				if (se1 != null)
-					se.setNextException(se1);
-				throw se;
-			} finally {
-				conn.setTxid_(currentTxid);
-			}
-			return startDataLocator_;
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_getStartDataLocator].methodExit();
-		}
-*/
-		return 0;	// Linux port - Temp added
-	}
-
-	void insertDataLocatorRow(SQLMXConnection conn) throws SQLException {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_insertDataLocatorRow].methodEntry();
-		try {
-			String lobInsDataLocRowSQL;
-
-			if (prepareInsert_) {
-				String lobGetMaxDataLocSQL = "select max(data_locator) from "
-						+ lobTableName_;
-				GetMaxDataLoc_ = conn.prepareLobStatement(lobGetMaxDataLocSQL);
-			}
-
-			ResultSet rs = GetMaxDataLoc_.executeQuery();
-			try {
-				if (rs.next()) {
-					startDataLocator_ = rs.getLong(1) + 1;
-
-					if ((traceWriter_ != null)
-							&& ((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL))) {
-						traceWriter_
-								.println(getTraceId()
-										+ "insertDataLocatorRow() - Retrieved startDataLocator_="
-										+ startDataLocator_ + " from "
-										+ lobTableName_);
-					}
-				}
-			} finally {
-				rs.close();
-			}
-
-			long dataLocVal = startDataLocator_
-					+ SQLMXConnection.reserveDataLocator_ - 1;
-
-			if ((traceWriter_ != null)
-					&& ((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL))) {
-				traceWriter_.println(getTraceId()
-						+ "insertDataLocatorRow() - dataLocVal=" + dataLocVal
-						+ " startDataLocator_=" + startDataLocator_
-						+ " lobCharSet_=" + lobCharSet_ + " prepareInsert_="
-						+ prepareInsert_ + " prepDataLocVal_="
-						+ prepDataLocVal_);
-			}
-
-			// Re-prepare special LOB table row if lobTableName_ has changed
-			// (prepareInsert_ flag)
-			// or if the data locator value has changed from previous statement
-			// prepare.
-			if (prepareInsert_ || (dataLocVal != prepDataLocVal_)) {
-				if (lobCharSet_.equals(SQLMXConnection.UCS_STR)) // Unicode data
-				{
-					lobInsDataLocRowSQL = "insert into "
-							+ lobTableName_
-							+ " (table_name, data_locator, chunk_no, lob_data) values ('ZZDATA_LOCATOR', 0, 0, cast("
-							+ dataLocVal
-							+ " as VARCHAR(100) character set UCS2))";
-				} else // ISO data
-				{
-					lobInsDataLocRowSQL = "insert into "
-							+ lobTableName_
-							+ " (table_name, data_locator, chunk_no, lob_data) values ('ZZDATA_LOCATOR', 0, 0, cast("
-							+ dataLocVal + " as VARCHAR(100)))";
-				}
-				InsDataLocRow_ = conn.prepareLobStatement(lobInsDataLocRowSQL);
-				prepDataLocVal_ = dataLocVal;
-				prepareInsert_ = false;
-			}
-
-			InsDataLocRow_.executeUpdate();
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_insertDataLocatorRow].methodExit();
-		}
-	}
-
-	void prepareGetStrtDataLocStmt(SQLMXConnection conn) throws SQLException {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_prepareGetStrtDataLocStmt].methodEntry();
-		try {
-			/*
-			 * Description: JDBC no longer throws
-			 * "Connection does not exist" for an active connection.
-			 */
-			if (conn.prepareGetStrtDataLocStmt(lobTableName_, isBlob_,
-					lobCharSet_)
-					|| (GetStrtDataLoc_.getConnection() != conn)) {
-				if (isBlob_) {
-					GetStrtDataLoc_ = conn.LobPrepStmts[SQLMXConnection.BLOB_GET_STRT_DATA_LOC_STMT];
-				} else {
-					GetStrtDataLoc_ = conn.LobPrepStmts[SQLMXConnection.CLOB_GET_STRT_DATA_LOC_STMT];
-				}
-				// Set flag to re-prepare next two LOB statements in the path
-				// (GetMaxDataLoc_ and InsDataLocRow_)
-				prepareInsert_ = true;
-			}
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_prepareGetStrtDataLocStmt].methodExit();
-		}
-	}
-
-	SQLMXDataLocator(SQLMXConnection conn, String lobTableName)
-			throws SQLException {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_SQLMXDataLocator].methodEntry();
-		try {
-
-
-			lobTableName_ = lobTableName;
-			// Obtain the precision of the lob_data column to set the
-			// appropriate
-			// chunk size for LOB data operations.
-			String s = "select lob_data from " + lobTableName
-					+ " where table_name = 'ZZDATA_LOCATOR' ";
-			PreparedStatement ps = conn.prepareLobStatement(s);
-			ResultSetMetaData rsmd = ps.getMetaData();
-			lobCharSet_ = ((SQLMXResultSetMetaData) rsmd).cpqGetCharacterSet(1);
-
-			// Set appropriate chunkSize_ based on character set type
-			if (lobCharSet_.equals(SQLMXConnection.UCS_STR)) {
-				chunkSize_ = (rsmd.getPrecision(1)) / 2;
-			} else {
-				chunkSize_ = rsmd.getPrecision(1);
-			}
-
-			if ((traceWriter_ != null)
-					&& ((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL))) {
-				traceWriter_.println(getTraceId()
-						+ "SQLMXDataLocator() - constructor chunkSize_="
-						+ chunkSize_ + " lobTableName=" + lobTableName);
-			}
-
-			ps.close();
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_SQLMXDataLocator].methodExit();
-		}
-	}
-	public void setTraceId(String traceId_) {
-		this.traceId_ = traceId_;
-	}
-
-	public String getTraceId() {
-		traceWriter_ = SQLMXDataSource.traceWriter_;
-
-		// Build up template portion of jdbcTrace output. Pre-appended to
-		// jdbcTrace entries.
-		// jdbcTrace:[XXXX]:[Thread[X,X,X]]:[XXXXXXXX]:ClassName.
-		if (traceWriter_ != null) {
-			traceFlag_ = T2Driver.traceFlag_;
-			String className = getClass().getName();
-			setTraceId(T2Driver.traceText
-					+ T2Driver.dateFormat.format(new Date())
-					+ "]:["
-					+ Thread.currentThread()
-					+ "]:["
-					+ hashCode()
-					+ "]:"
-					+ className.substring(T2Driver.REMOVE_PKG_NAME,
-							className.length()) + ".");
-		}
-		return traceId_;
-	}
-
-	// Fields
-	private String traceId_;
-	static PrintWriter traceWriter_;
-	static int traceFlag_;
-	String lobTableName_;
-	String lobCharSet_;
-	long startDataLocator_;
-	long currentDataLocator_;
-	int chunkSize_;
-	long prepDataLocVal_;
-	boolean isBlob_;
-	boolean prepareInsert_ = false;
-
-	PreparedStatement GetStrtDataLoc_;
-	PreparedStatement GetMaxDataLoc_;
-	PreparedStatement InsDataLocRow_;
-
-	private static int methodId_getDataLocator = 0;
-	private static int methodId_getStartDataLocator = 1;
-	private static int methodId_insertDataLocatorRow = 2;
-	private static int methodId_prepareGetStrtDataLocStmt = 3;
-	private static int methodId_SQLMXDataLocator = 4;
-	private static int totalMethodIds = 5;
-	private static JdbcDebug[] debug;
-
-	static {
-		String className = "SQLMXDataLocator";
-		if (JdbcDebugCfg.entryActive) {
-			debug = new JdbcDebug[totalMethodIds];
-			debug[methodId_getDataLocator] = new JdbcDebug(className,
-					"getDataLocator");
-			debug[methodId_getStartDataLocator] = new JdbcDebug(className,
-					"getStartDataLocator");
-			debug[methodId_insertDataLocatorRow] = new JdbcDebug(className,
-					"insertDataLocatorRow");
-			debug[methodId_prepareGetStrtDataLocStmt] = new JdbcDebug(
-					className, "prepareGetStrtDataLocStmt");
-			debug[methodId_SQLMXDataLocator] = new JdbcDebug(className,
-					"SQLMXDataLocator");
-		}
-	}
-}
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDataSource.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDataSource.java
index 0579079..1233f3a 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDataSource.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDataSource.java
@@ -194,7 +194,7 @@
 //					mxConnect = new SQLMXConnection(this,getDataSourceProperties());
 					mxConnect = new SQLMXConnection(this,getT2Properties());
 					weakConnection.refToDialogueId_.put(mxConnect.pRef_, new Long(mxConnect
-							.getDialogueId_()));
+							.getDialogueId()));
 				} else {
 
 					int maxSt = getMaxStatements();
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDatabaseMetaData.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDatabaseMetaData.java
index 7741794..1f041a2 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDatabaseMetaData.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXDatabaseMetaData.java
@@ -51,7 +51,7 @@
  * 
  */
 /*
- * Methods Changed: getTxid_() changes 
+ * Methods Changed: getTxid() changes 
  */
 
 public class SQLMXDatabaseMetaData extends SQLMXHandle implements
@@ -2528,7 +2528,7 @@
 				else
 					schemaNm = schemaPattern;
 				resultSet = getProcedures(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, procedureNamePattern);
 			}// End sync
@@ -2634,7 +2634,7 @@
 				else
 					schemaNm = schemaPattern;
 				resultSet = getProcedureColumns(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, procedureNamePattern,
 						columnNamePattern);
@@ -2749,7 +2749,7 @@
 				} else
 					tableTypeList = null;
 				resultSet = getTables(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, tableNm, tableTypeList);
 			}// End sync
@@ -2792,7 +2792,7 @@
 					throw Messages.createSQLException(connection_.locale_,
 							"invalid_connection", null);
 				resultSet = getSchemas(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						"%");
 			}// End sync
@@ -2834,7 +2834,7 @@
 					throw Messages.createSQLException(connection_.locale_,
 							"invalid_connection", null);
 				resultSet = getCatalogs(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						"%");
 			}// End sync
@@ -2882,7 +2882,7 @@
 					null, 100, 0, 0, null);
 
 			resultSet = new SQLMXResultSet(this, outputDesc, connection_
-					.getTxid_(), 0);
+					.getTxid(), 0);
 			rows = new DataWrapper[3];
 
 			// Populate the rows
@@ -2895,7 +2895,7 @@
 			rows[2] = new DataWrapper(1);
 			rows[2].setString(1, new String("VIEW"));
 
-			resultSet.setFetchOutputs(rows, 3, true, connection_.getTxid_());
+			resultSet.setFetchOutputs(rows, 3, true, connection_.getTxid());
 			return resultSet;
 		} finally {
 			if (JdbcDebugCfg.entryActive)
@@ -3008,7 +3008,7 @@
 					columnNm = columnNamePattern;
 
 				resultSet = getColumns(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, tableNm, columnNm);
 			}// End sync
@@ -3092,7 +3092,7 @@
 					schemaNm = schema;
 
 				resultSet = getColumnPrivileges(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table, columnNamePattern);
 			}// End sync
@@ -3172,7 +3172,7 @@
 					schemaNm = schema;
 
 				resultSet = getTablePrivileges(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table);
 			}// End sync
@@ -3261,7 +3261,7 @@
 				else
 					schemaNm = schema;
 				resultSet = getBestRowIdentifier(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table, scope, nullable);
 			}// End sync
@@ -3338,7 +3338,7 @@
 				else
 					schemaNm = schema;
 				resultSet = getVersionColumns(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table);
 			}// End sync
@@ -3406,7 +3406,7 @@
 				else
 					schemaNm = schema;
 				resultSet = getPrimaryKeys(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table);
 			}// End sync
@@ -3519,7 +3519,7 @@
 					schemaNm = schema;
 
 				resultSet = getImportedKeys(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table);
 			}// End sync
@@ -3633,7 +3633,7 @@
 					schemaNm = schema;
 
 				resultSet = getExportedKeys(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table);
 			}// End sync
@@ -3770,7 +3770,7 @@
 					foreignSchemaNm = foreignSchema;
 
 				resultSet = getCrossReference(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						primaryCatalogNm, primarySchemaNm, primaryTable,
 						foreignCatalogNm, foreignSchemaNm, foreignTable);
@@ -3847,7 +3847,7 @@
 					throw Messages.createSQLException(connection_.locale_,
 							"invalid_connection", null);
 				resultSet = getTypeInfo(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_);
 			}// End sync
 			// Patch the column names as per JDBC specification
@@ -3952,7 +3952,7 @@
 				else
 					schemaNm = schema;
 				resultSet = getIndexInfo(connection_.server_,
-						connection_.getDialogueId_(), connection_.getTxid_(),
+						connection_.getDialogueId(), connection_.getTxid(),
 						connection_.autoCommit_, connection_.transactionMode_,
 						catalogNm, schemaNm, table, unique, approximate);
 			}// End sync
@@ -4108,11 +4108,11 @@
 					null, 130, 0, 0, null);
 
 			resultSet = new SQLMXResultSet(this, outputDesc, connection_
-					.getTxid_(), 0);
+					.getTxid(), 0);
 			rows = new DataWrapper[0];
 
 			// Populate the rows
-			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid_());
+			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid());
 			return resultSet;
 		} finally {
 			if (JdbcDebugCfg.entryActive)
@@ -4556,11 +4556,11 @@
 					(short) 0, 0, null, null, null, 100, 0, 0, null);
 
 			resultSet = new SQLMXResultSet(this, outputDesc, connection_
-					.getTxid_(), 0);
+					.getTxid(), 0);
 			rows = new DataWrapper[0];
 
 			// Populate the rows
-			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid_());
+			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid());
 			return resultSet;
 		} finally {
 			if (JdbcDebugCfg.entryActive)
@@ -4644,11 +4644,11 @@
 					(short) 0, 0, null, null, null, 100, 0, 0, null);
 
 			resultSet = new SQLMXResultSet(this, outputDesc, connection_
-					.getTxid_(), 0);
+					.getTxid(), 0);
 			rows = new DataWrapper[0];
 
 			// Populate the rows
-			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid_());
+			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid());
 			return resultSet;
 		} finally {
 			if (JdbcDebugCfg.entryActive)
@@ -4833,11 +4833,11 @@
 					(short) 0, 0, null, null, null, 130, 0, 0, null);
 
 			resultSet = new SQLMXResultSet(this, outputDesc, connection_
-					.getTxid_(), 0);
+					.getTxid(), 0);
 			rows = new DataWrapper[0];
 
 			// Populate the rows
-			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid_());
+			resultSet.setFetchOutputs(rows, 0, true, connection_.getTxid());
 			return resultSet;
 		} finally {
 			if (JdbcDebugCfg.entryActive)
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java
index f48c3ba..e8551e1 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLob.java
@@ -40,113 +40,11 @@
 	// public methods
 	public long length() throws SQLException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_length].methodEntry();
-		try
-		{
-			long length = 0;
-
-			checkIfCurrent();
-			prepareGetLobLenStmt();
-			PreparedStatement GetLobLenStmt = getGetLobLenStmt();
-
-			if ((traceWriter_ != null) &&
-				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-			{
-				traceWriter_.println(getTraceId()
-					+ "length() - GetLobLenStmt params: tableName_=" + tableName_
-					+ " dataLocator_=" + dataLocator_);
-			}
-
-			synchronized (GetLobLenStmt)
-			{
-				GetLobLenStmt.setString(1, tableName_);
-				GetLobLenStmt.setLong(2, dataLocator_);
-				ResultSet rs = GetLobLenStmt.executeQuery();
-				try
-				{
-					if (rs.next())
-						length = rs.getLong(1);
-				}
-				finally
-				{
-					rs.close();
-				}
-			}
-			return length;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_length].methodExit();
-		}
+		return  isLength_;
 	}
 
 	public void truncate(long len) throws SQLException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_truncate].methodEntry();
-		try
-		{
-			int chunkNo;
-			int offset;
-			byte[] chunk;
-
-			if (len < 0)
-			{
-				Object[] messageArguments = new Object[1];
-				messageArguments[0] = "SQLMXLob.truncate(long)";
-				throw Messages.createSQLException(conn_.locale_,"invalid_input_value", messageArguments);
-			}
-			checkIfCurrent();
-			chunkNo = (int)(len / chunkSize_);
-			offset = (int)(len % chunkSize_);
-			prepareDelLobDataStmt();
-			PreparedStatement DelLobStmt = getDelLobDataStmt();
-
-			if ((traceWriter_ != null) &&
-				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-			{
-				traceWriter_.println(getTraceId()
-					+ "truncate(" + len + ") - DelLobStmt params: tableName_=" + tableName_
-					+ " dataLocator_=" + dataLocator_
-					+ " chunkNo+1=" + chunkNo+1);
-			}
-
-			synchronized (DelLobStmt)
-			{
-				DelLobStmt.setString(1, tableName_);
-				DelLobStmt.setLong(2, dataLocator_);
-				DelLobStmt.setInt(3, chunkNo+1);
-				DelLobStmt.setInt(4, Integer.MAX_VALUE);
-				DelLobStmt.executeUpdate();
-			}
-			if (offset != 0)
-			{
-				prepareTrunLobDataStmt();
-				PreparedStatement TrunLobStmt = getTrunLobDataStmt();
-
-				if ((traceWriter_ != null) &&
-					((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-				{
-					traceWriter_.println(getTraceId()
-						+ "truncate(" + len + ") - TrunLobStmt params: offset=" + offset
-						+ " tableName_=" + tableName_
-						+ " dataLocator_=" + dataLocator_
-						+ " chunkNo=" + chunkNo);
-				}
-
-				synchronized (TrunLobStmt)
-				{
-					TrunLobStmt.setInt(1, offset);
-					TrunLobStmt.setString(2, tableName_);
-					TrunLobStmt.setLong(3, dataLocator_);
-					TrunLobStmt.setInt(4, chunkNo);
-					TrunLobStmt.executeUpdate();
-				}
-			}
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_truncate].methodExit();
-		}
 	}
 
 	InputStream getInputStream() throws SQLException
@@ -178,60 +76,21 @@
 		}
 	}
 
-	OutputStream setOutputStream(long pos) throws SQLException
+	SQLMXLobOutputStream setOutputStream(long startingPos) throws SQLException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_setOutputStream].methodEntry();
-		try
-		{
-			if (outputStream_ != null)
-			{
-				try
-				{
-					outputStream_.close();
-				}
-				catch (IOException e)
-				{
-				}
-				finally
-				{
-					outputStream_ = null;
-				}
-			}
-			outputStream_ = new SQLMXLobOutputStream(conn_, this, pos);
-			return outputStream_;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_setOutputStream].methodExit();
-		}
+		outputStream_ = new SQLMXLobOutputStream(conn_, startingPos, this);
+		return outputStream_;
 	}
 
 
-	void close()
+	void close() throws SQLException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_close].methodEntry();
-		try
-		{
+		try {
+			if (inputStream_ != null)
+				inputStream_.close();
 			isCurrent_ = false;
-			try
-			{
-				if (inputStream_ != null)
-					inputStream_.close();
-				if (outputStream_ != null)
-					outputStream_.close();
-			}
-			catch (IOException e)
-			{
-			}
-			finally
-			{
-				inputStream_ = null;
-				outputStream_ = null;
-			}
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_close].methodExit();
+		} catch (IOException ioe) {
+			throw new SQLException(ioe);
 		}
 	}
 
@@ -262,7 +121,7 @@
 		}
 	}
 
-	void checkIfCurrent() throws SQLException
+        void checkIfCurrent() throws SQLException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_checkIfCurrent].methodEntry();
 		try
@@ -281,6 +140,7 @@
 		}
 	}
 
+
 // *******************************************************************
 // * If Autocommit is enabled, and no external transaction exists, an
 // * exception will be thrown. In this case, JDBC cannot play the role of
@@ -324,69 +184,28 @@
 		}
 	}
 
-    // Declare the following abstract methods to resolve symbols
-	abstract void prepareGetLobLenStmt() throws SQLException;
-	abstract void prepareDelLobDataStmt()  throws SQLException;
-	abstract void prepareGetLobDataStmt() throws SQLException;
-	abstract void prepareUpdLobDataStmt() throws SQLException;
-	abstract void prepareInsLobDataStmt() throws SQLException;
-	abstract void prepareTrunLobDataStmt() throws SQLException;
-	abstract PreparedStatement getGetLobLenStmt();
-	abstract PreparedStatement getDelLobDataStmt();
-	abstract PreparedStatement getTrunLobDataStmt();
-	abstract PreparedStatement getInsLobDataStmt();
-	abstract PreparedStatement getUpdLobDataStmt();
-	abstract PreparedStatement getGetLobDataStmt();
-
-
-
-	// Constructors
-	SQLMXLob(SQLMXConnection connection, String tableName, long dataLocator, String lobTableName, boolean isBlob)
-		throws SQLException
+	void setLobLocator(String lobLocator)
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJL].methodEntry();
-		try
-		{
-			conn_ = connection;
-			tableName_ = tableName;
-			isCurrent_ = true;
-			dataLocator_ = dataLocator;
-			if (lobTableName != null)
-			{
-				lobTableName_ = lobTableName;
-				SQLMXDataLocator tempLoc = (SQLMXDataLocator)SQLMXConnection.lobTableToDataLoc_.get(lobTableName);
-				if (tempLoc == null)
-				{
-					dataLocator = conn_.getDataLocator(lobTableName_, isBlob);
-				}
-				SQLMXDataLocator dataLoc = (SQLMXDataLocator)SQLMXConnection.lobTableToDataLoc_.get(lobTableName);
-				chunkSize_ = dataLoc.chunkSize_;
-			}
-
-
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJL].methodExit();
-		}
+		lobLocator_ = lobLocator;
 	}
 
-	SQLMXLob(SQLMXConnection connection, String tableName, long dataLocator, InputStream x,
-		int length, String lobTableName, boolean isBlob) throws SQLException
+	SQLMXLob(SQLMXConnection connection, String lobLocator, boolean isBlob) throws SQLException
 	{
-		this(connection, tableName, dataLocator, lobTableName, isBlob);
-
-		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJLIL].methodEntry();
-		try
-		{
-			is_ = x;
-			isLength_ = length;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLob_LLJLIL].methodExit();
-		}
+		lobLocator_ = lobLocator;
+		conn_ = connection;
+		isBlob_ = isBlob;
+		chunkSize_ = 16*1024;
+		isCurrent_ = true;
 	}
+
+	SQLMXLob(SQLMXConnection connection, String lobLocator, InputStream x, long length, boolean isBlob) throws SQLException
+	{
+		this(connection, lobLocator, isBlob);
+		is_ = x;
+		isLength_ = length;
+		isCurrent_ = true;
+	}
+
 	public void setTraceId(String traceId_) {
 		this.traceId_ = traceId_;
 	}
@@ -408,31 +227,30 @@
 		return traceId_;
 	}
 	// fields
-	private String					traceId_;
+	private String			traceId_;
 	static PrintWriter		traceWriter_;
-	static int				traceFlag_;
+	static int			traceFlag_;
 	SQLMXConnection			conn_;
-	String					tableName_;
-	long					dataLocator_;
+	String				lobLocator_;
 	SQLMXLobInputStream		inputStream_;
-	SQLMXLobOutputStream	outputStream_;
-	boolean					isCurrent_;
-	InputStream				is_;
-	int						isLength_;
-	String					lobTableName_;
-	int						chunkSize_;
-
-	private static int methodId_length					=  0;
+	SQLMXLobOutputStream		outputStream_;
+	boolean				isCurrent_;
+	InputStream			is_;
+	long				isLength_;
+	int				chunkSize_;
+	boolean				isBlob_;
+	
+	private static int methodId_length				=  0;
 	private static int methodId_truncate				=  1;
 	private static int methodId_getInputStream			=  2;
 	private static int methodId_setOutputStream			=  3;
-	private static int methodId_close					=  4;
-	private static int methodId_convSQLExceptionToIO	=  5;
+	private static int methodId_close				=  4;
+	private static int methodId_convSQLExceptionToIO		=  5;
 	private static int methodId_checkIfCurrent			=  6;
-	private static int methodId_checkAutoCommitExtTxn	=  7;
+	private static int methodId_checkAutoCommitExtTxn		=  7;
 	private static int methodId_SQLMXLob_LLJL			=  8;
 	private static int methodId_SQLMXLob_LLJLIL			=  9;
-	private static int totalMethodIds					= 10;
+	private static int totalMethodIds				= 10;
 	private static JdbcDebug[] debug;
 
 	static
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java
index f4cf5e4..d09cfc6 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobInputStream.java
@@ -35,72 +35,38 @@
 import java.io.IOException;
 import java.util.Date;
 import java.io.PrintWriter;
+import java.nio.ByteBuffer;
 
 public class SQLMXLobInputStream extends InputStream
 {
 	public int available() throws IOException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_available].methodEntry();
-		try
-		{
-			long length;
-			long readLength;
+		int remainLen;
 
-			if (isClosed_)
-				throw new IOException("Input stream is in closed state");
-			try
-			{
-				length = lob_.length();
-				if (currentChunkNo_ > 0)
-					readLength = ((currentChunkNo_-1) * lob_.chunkSize_) + currentByte_;
-				else
-					readLength = currentByte_;
-				return (int)(length - readLength);
-			}
-			catch (SQLException e)
-			{
-				throw new IOException(SQLMXLob.convSQLExceptionToIO(e));
-			}
+		if (isClosed_)
+			throw new IOException("Input stream is in closed state");
+		if (eos_)
+			remainLen = 0;
+		else {
+			remainLen = bytesRead_ - currentPos_;
+			if (remainLen == 0) // 0 would mean all the bytes are read from chunk_
+				remainLen = lob_.chunkSize_;
 		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_available].methodExit();
-		}
+		return remainLen;
 	}
 
 	public void close() throws IOException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_close].methodEntry();
-		try
-		{
-			isClosed_ = true;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_close].methodExit();
-		}
+		isClosed_ = true;
 	}
 
 	public void mark(int readlimit)
 	{
-		if (JdbcDebugCfg.entryActive)
-		{
-			debug[methodId_mark].methodEntry();
-			debug[methodId_mark].methodExit();
-		}
 	}
 
 	public boolean markSupported()
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_markSupported].methodEntry();
-		try
-		{
-			return false;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_markSupported].methodExit();
-		}
+		return false;
 	}
 
 	public int read() throws IOException
@@ -112,17 +78,14 @@
 
 			if (isClosed_)
 				throw new IOException("Input stream is in closed state");
-			if (currentByte_ == bytesRead_)
-				retValue = readChunkThrowIO(null, 0, lob_.chunkSize_);
+			if (eos_)
+				throw new IOException("End of stream already reached");
+			if (currentPos_ == bytesRead_)
+				retValue = readChunkThrowIO();
 			if (retValue != -1)
 			{
-				retValue = chunk_[currentByte_];
-				// Should be a value between 0 and 255 
-				// -1 is mapped to 255, -2 is 254 etc
-				if (retValue < 0)
-					retValue = 256 + retValue; 
-				if (currentByte_ != bytesRead_)
-					currentByte_++;
+				retValue = chunk_.get();
+				currentPos_++;
 			}
 			return retValue;
 		}
@@ -134,65 +97,60 @@
 
 	public int read(byte[] b) throws IOException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_read_B].methodEntry();
-		try
-		{
-			if (b == null)
-				throw new IOException("Invalid input value");
-			return read(b, 0, b.length);
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_read_B].methodExit();
-		}
+		return read(b, 0, b.length);
 	}
 
 	public int read(byte[] b, int off, int len) throws IOException
 	{
+		return read(b, off, len, false);
+	}
+
+	public int read(byte[] b, int off, int len, boolean skip) throws IOException
+	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_read_BII].methodEntry();
 		try
 		{
-			int readLen;
+			int remainLen;
 			int copyLen;
 			int copyOffset;
-			int tempLen = 0;
 			int retLen;
+			int availableLen;
+			int copiedLen = 0;
 
 			if (isClosed_)
 				throw new IOException("Input stream is in closed state");
 			if (b == null)
 				throw new IOException("Invalid input value");
-			copyLen = len;
+			if (eos_)
+				throw new IOException("End of stream already reached");
+			remainLen = len;
 			copyOffset = off;
-			readLen = 0;
-			if (currentByte_ < bytesRead_)
-			{
-				if (copyLen+currentByte_ <= bytesRead_)
-				{
-					System.arraycopy(chunk_, currentByte_, b, copyOffset, copyLen);
-					currentByte_ += copyLen;
-					readLen = copyLen;
-					return readLen;
-				}
+			
+			while (remainLen > 0) {
+				availableLen = bytesRead_ - currentPos_;
+				if (availableLen > remainLen)	
+					copyLen = remainLen;
 				else
-				{
-					tempLen = bytesRead_- currentByte_;
-					System.arraycopy(chunk_, currentByte_, b, copyOffset, tempLen);
-					copyOffset += tempLen;
-					copyLen -= tempLen;
-					currentByte_ += tempLen;
+					copyLen = availableLen;
+				if (copyLen > 0) {
+					if (! skip)
+						chunk_.get(b, copyOffset, copyLen);			
+					else
+						chunk_.position(currentPos_+copyLen);
+					currentPos_ += copyLen;
+					copyOffset += copyLen;
+					copiedLen += copyLen;
+					remainLen -= copyLen;
+		
+				}
+				if (remainLen > 0) {
+					retLen = readChunkThrowIO();
+					if (retLen == -1)
+						break;
 				}
 			}
-			readLen = readChunkThrowIO(b, copyOffset, copyLen);
-			if (readLen != -1)
-				retLen = readLen + tempLen;
-			else
-				retLen = tempLen;
-			if (retLen == 0)
-				return -1;
-			else
-				return retLen;
-		}
+			return copiedLen;
+		}		
 		finally
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_read_BII].methodExit();
@@ -206,8 +164,7 @@
 		{
 			if (isClosed_)
 				throw new IOException("Input stream is in closed state");
-			currentByte_ = 0;
-			currentChunkNo_ = 0;
+			currentPos_ = 0;
 			bytesRead_ = 0;
 			return;
 		}
@@ -219,87 +176,34 @@
 
 	public long skip(long n) throws IOException
 	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_skip].methodEntry();
-		try
-		{
-			long bytesToSkip;
-			int noOfChunks = 0;
-			int remBytes;
-			long retLen = -1;
-			long bytesSkipped = 0;
-			int oldChunkNo;
-
-			if (isClosed_)
-				throw new IOException("Input stream is in closed state");
-			if (n <= 0)
-				throw new IOException("Invalid input Value");
-			if (currentByte_ + n > bytesRead_)
-			{
-				bytesSkipped = bytesRead_ - currentByte_;
-				bytesToSkip = n - bytesSkipped;
-				currentByte_ += bytesSkipped;
-			}
+		long totalSkippedLen = 0;
+		long skipRemain = n;
+		int skipLen;
+		int skippedLen;
+		while (skipRemain > 0) {
+			if (skipRemain <= Integer.MAX_VALUE)
+				skipLen = (int)skipRemain;
 			else
-			{
-				currentByte_ += n;
-				return n;
-			}
-			noOfChunks += (int)((bytesToSkip-1)/ lob_.chunkSize_);
-			if ((bytesToSkip % lob_.chunkSize_) == 0)
-				remBytes = lob_.chunkSize_;
-			else
-				remBytes = (int)(bytesToSkip % lob_.chunkSize_);
-			oldChunkNo = currentChunkNo_;	// Which is already 1 more
-			currentChunkNo_ = currentChunkNo_ + noOfChunks;
-			retLen = readChunkThrowIO(null, 0, lob_.chunkSize_);
-			if (retLen != -1)
-			{
-				bytesSkipped += (currentChunkNo_ - oldChunkNo - 1) * lob_.chunkSize_;
-				if (retLen < remBytes)
-					remBytes = (int)retLen;
-				currentByte_ = remBytes;
-				bytesSkipped += remBytes;
-			}
-			else
-			{
-				bytesSkipped += available();
-				// Exclude the bytes that are in chunk already
-				remBytes = (int)(bytesSkipped - (bytesRead_ - currentByte_));
-				noOfChunks += (int)((remBytes-1) / lob_.chunkSize_);
-				currentChunkNo_ = oldChunkNo + noOfChunks;
-				//calculate the bytes in the chunk and set currentByte and bytesRead
-				//to reach EOD
-				if (remBytes == 0)
-				{
-					currentByte_ = 0;
-					bytesRead_ = 0;
-				}
-				else
-				{
-					if ((remBytes % lob_.chunkSize_) == 0)
-						currentByte_ = lob_.chunkSize_;
-					else
-						currentByte_ = (int)(remBytes % lob_.chunkSize_);
-					bytesRead_ = currentByte_;
-				}
-			}
-			return bytesSkipped;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_skip].methodExit();
-		}
+				skipLen = Integer.MAX_VALUE;	
+			skippedLen = read(null, 0, skipLen, true); 
+			if (skippedLen == -1)
+				break;
+			skipRemain -= skippedLen;
+			totalSkippedLen += skippedLen;
+		}	
+		return totalSkippedLen;
 	}
 
-	int readChunkThrowIO(byte[] b, int off, int len) throws IOException
+	int readChunkThrowIO() throws IOException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_readChunkThrowIO].methodEntry();
 		try
 		{
 			int readLen;
+
 			try
 			{
-				readLen = readChunk(b, off, len);
+				readLen = readChunk();
 			}
 			catch (SQLException e)
 			{
@@ -311,104 +215,31 @@
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_readChunkThrowIO].methodExit();
 		}
-	} 
-
-	int readChunk(byte[] b, int off, int len) throws SQLException
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_readChunk].methodEntry();
-		try
-		{
-			int endChunkNo;
-			byte[]	data;
-			int copyLen;
-			int	copyOffset;
-			int readLen = 0;
-
-			// The rows to read is calculated via ((len-1)/lob_.chunkSize_)
-			endChunkNo = currentChunkNo_ + ((len-1)/lob_.chunkSize_);
-			lob_.prepareGetLobDataStmt();
-			PreparedStatement GetLobStmt = lob_.getGetLobDataStmt();
-
-			if ((traceWriter_ != null) && 
-				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-			{
-				traceWriter_.println(getTraceId() 
-					+ "readChunk(<byte>," + off + "," + len + ") - GetLobDataStmt params: tableName_=" + lob_.tableName_ 
-					+ " dataLocator_=" + lob_.dataLocator_
-					+ " currentChunkNo_=" + currentChunkNo_
-					+ " endChunkNo=" + endChunkNo);
-			}
-
-			synchronized (GetLobStmt)
-			{
-				GetLobStmt.setString(1, lob_.tableName_);
-				GetLobStmt.setLong(2, lob_.dataLocator_);
-				GetLobStmt.setInt(3, currentChunkNo_);
-				GetLobStmt.setInt(4, endChunkNo);
-				ResultSet rs = GetLobStmt.executeQuery();
-				copyLen = len;
-				copyOffset = off;
-				try 
-				{
-					while (rs.next())
-					{
-						data = rs.getBytes(1);
-						currentChunkNo_++;
-						bytesRead_ = data.length;
-						if (b == null)
-						{
-							System.arraycopy(data, 0, chunk_, 0, data.length);
-							readLen += data.length;
-							currentByte_ = 0;
-							break;				
-						}
-						else
-						{
-							if (copyLen >= data.length)
-							{
-								System.arraycopy(data, 0, b, copyOffset, data.length);
-								copyLen -= data.length;
-								readLen += data.length;
-								copyOffset += data.length;
-								currentByte_ = data.length;
-							} 
-							else
-							{
-								System.arraycopy(data, 0, b, copyOffset, copyLen);
-								// copy the rest of data to chunk
-								System.arraycopy(data, copyLen, chunk_, copyLen, data.length - copyLen);
-								readLen += copyLen;
-								currentByte_ = copyLen;
-								break;
-							}
-						}
-					}
-				} 
-				finally 
-				{
-					rs.close();
-				}
-			}
-			
-			if ((traceWriter_ != null) && 
-				((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-			{
-				traceWriter_.println(getTraceId() 
-					+ "readChunk(<byte>," + off + "," + len + ") - LOB data read: bytesRead_=" + bytesRead_ 
-					+ " readLen=" + readLen + " copyLen=" + copyLen + " currentChunkNo_=" + currentChunkNo_);
-			}
-
-			if (readLen == 0)
-				return -1;
-			else
-				return readLen;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_readChunk].methodExit();
-		}
 	}
 
+	int readChunk() throws SQLException
+	{
+		int extractMode = 1; // get the lob data
+		chunk_.clear(); 
+		if (eos_)
+			return -1;
+		if (bytesRead_ != 0 && (bytesRead_ < lob_.chunkSize_)) {
+			eos_ = true;
+			extractMode = 2; // Close the extract
+		}
+		bytesRead_ = readChunk(conn_.server_, conn_.getDialogueId(), conn_.getTxid(), extractMode, lob_.lobLocator_, chunk_); 
+		if (bytesRead_ == -1) {
+			extractMode = 2; // close the extract
+		 	readChunk(conn_.server_, conn_.getDialogueId(), conn_.getTxid(), extractMode, lob_.lobLocator_, chunk_); 
+			eos_ = true;
+		}
+                else
+			chunk_.limit(bytesRead_);
+		return bytesRead_;
+	}
+
+        native int readChunk(String server, long dialogueId, long txid,  long extractMode, String lobLocator, ByteBuffer buffer);
+
 	// Constructor
 	SQLMXLobInputStream(SQLMXConnection connection, SQLMXLob lob)
 	{
@@ -417,9 +248,10 @@
 		{
 			lob_ = lob;
 			conn_ = connection;
-			chunk_ = new byte[lob_.chunkSize_];
-
-			
+			chunk_ = ByteBuffer.allocateDirect(lob_.chunkSize_);
+			bytesRead_ = 0;
+			currentPos_ = 0;
+			eos_ = false;
 		}
 		finally
 		{
@@ -449,16 +281,16 @@
 	
 
 	// Fields
-	private String				traceId_;
+	private String		traceId_;
 	static PrintWriter	traceWriter_;
-	static int			traceFlag_;
-	SQLMXLob			lob_;
+	static int		traceFlag_;
+	SQLMXLob		lob_;
 	SQLMXConnection		conn_;
-	boolean				isClosed_;
-	byte[]				chunk_;
-	int					currentByte_;
-	int					currentChunkNo_;
-	int					bytesRead_;
+	boolean			isClosed_;
+	ByteBuffer		chunk_;
+	int			currentPos_;
+	int			bytesRead_;
+	boolean 		eos_;
 
 	private static int methodId_available			=  0;
 	private static int methodId_close				=  1;
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java
index 64da030..f25896e 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXLobOutputStream.java
@@ -63,8 +63,10 @@
 		{
 			if (isClosed_)
 				throw new IOException("Output stream is in closed state");
-			if (! isFlushed_)
-				writeChunkThrowIO();
+			if (! isFlushed_) {
+				writeChunkThrowIO(chunk_, 0, currentByte_);
+				currentByte_ = 0;
+			}
 		}
 		finally
 		{
@@ -72,6 +74,28 @@
 		}
 	}
 
+	public void write(int b) throws IOException
+	{
+		if (JdbcDebugCfg.entryActive) debug[methodId_write_I].methodEntry();
+		try
+		{
+			if (isClosed_)
+				throw new IOException("Output stream is in closed state");
+			chunk_[currentByte_] = (byte)b;
+			isFlushed_ = false;
+			currentByte_++;
+			if (currentByte_ == lob_.chunkSize_) {
+				writeChunkThrowIO(chunk_, 0, currentByte_);
+				currentByte_ = 0;
+			}
+		}
+		finally
+		{
+			if (JdbcDebugCfg.entryActive) debug[methodId_write_I].methodExit();
+		}
+	}
+
+
 	public void write(byte[] b) throws IOException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_write_B].methodEntry();
@@ -93,7 +117,7 @@
 		try
 		{
 			int copyLen;
-			int	srcOffset;
+			int srcOffset;
 			int tempLen;
 
 			if (isClosed_)
@@ -105,26 +129,26 @@
 					"length or offset is less than 0 or offset is greater than the length of array");
 			srcOffset = off;
 			copyLen = len;
-			while (true)
-			{
-				if ((copyLen+currentByte_) < lob_.chunkSize_)
-				{
+			while (true) {
+				if ((copyLen+currentByte_) < lob_.chunkSize_) {
 					System.arraycopy(b, srcOffset, chunk_, currentByte_, copyLen);
 					currentByte_ += copyLen;
 					isFlushed_ = false;
 					break;
-				}
-				else
-				{
-					tempLen = lob_.chunkSize_-currentByte_;		
-					System.arraycopy(b, srcOffset, chunk_, currentByte_, tempLen);
-					currentByte_ += tempLen;
-					writeChunkThrowIO();
+				} else {
+					if (currentByte_ != 0) {
+						tempLen = lob_.chunkSize_-currentByte_;		
+						System.arraycopy(b, srcOffset, chunk_, currentByte_, tempLen);
+						currentByte_ += tempLen;
+						writeChunkThrowIO(chunk_, 0, currentByte_);
+						currentByte_ = 0;
+					} else {
+						tempLen = lob_.chunkSize_;
+						writeChunkThrowIO(b, srcOffset, tempLen);
+					}
 					copyLen -= tempLen;
 					srcOffset += tempLen;
-					currentByte_ = 0;
 				}
-				
 			}
 		}
 		finally
@@ -132,99 +156,15 @@
 			if (JdbcDebugCfg.entryActive) debug[methodId_write_BII].methodExit();
 		}
 	}
-	
-	public void write(int b)
-		throws IOException
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_write_I].methodEntry();
-		try
-		{
-			if (isClosed_)
-				throw new IOException("Output stream is in closed state");
-			chunk_[currentByte_] = (byte)b;
-			isFlushed_ = false;
-			currentByte_++;
-			if (currentByte_ == lob_.chunkSize_)
-				writeChunkThrowIO();
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_write_I].methodExit();
-		}
-	}
 
-	void writeChunk() throws SQLException
-	{
-		if (JdbcDebugCfg.entryActive) debug[methodId_writeChunk].methodEntry();
-		try
-		{
-			byte[] tempChunk;
-
-			if (currentChunkNo_ > updChunkNo_)
-			{
-				lob_.prepareInsLobDataStmt();
-				PreparedStatement InsLobStmt = lob_.getInsLobDataStmt();
-
-				synchronized (InsLobStmt)
-				{
-					InsLobStmt.setString(1, lob_.tableName_);
-					InsLobStmt.setLong(2, lob_.dataLocator_);
-					InsLobStmt.setInt(3, currentChunkNo_);
-					if (currentByte_ != lob_.chunkSize_)
-					{
-						tempChunk = new byte[currentByte_];
-						System.arraycopy(chunk_, 0, tempChunk, 0, currentByte_);
-					}
-					else
-						tempChunk = chunk_;	
-					InsLobStmt.setBytes(4, tempChunk);
-					InsLobStmt.executeUpdate();
-					currentChunkNo_++;
-					currentByte_ = 0;
-				}
-			}
-			else
-			{
-				lob_.prepareUpdLobDataStmt();
-				PreparedStatement UpdLobStmt = lob_.getUpdLobDataStmt();
-
-				synchronized (UpdLobStmt)
-				{
-					UpdLobStmt.setString(4, lob_.tableName_);
-					UpdLobStmt.setLong(5, lob_.dataLocator_);
-					UpdLobStmt.setInt(6, currentChunkNo_);
-					UpdLobStmt.setInt(1, updOffset_);
-					if (updOffset_ != 0 || currentByte_ != lob_.chunkSize_)
-					{
-						tempChunk = new byte[currentByte_-updOffset_];
-						System.arraycopy(chunk_, updOffset_, tempChunk, 0, currentByte_-updOffset_);
-					}
-					else
-						tempChunk = chunk_;	
-					UpdLobStmt.setInt(3, currentByte_+1);
-					UpdLobStmt.setBytes(2, tempChunk);
-					UpdLobStmt.executeUpdate();
-					currentChunkNo_++;
-					currentByte_ = 0;
-					updOffset_ = 0;
-				}
-			}
-			isFlushed_ = true;
-		}
-		finally
-		{
-			if (JdbcDebugCfg.entryActive) debug[methodId_writeChunk].methodExit();
-		}
-	}
-
-	void writeChunkThrowIO() throws IOException
+        void writeChunkThrowIO(byte[] chunk, int off, int len) throws IOException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_writeChunkThrowIO].methodEntry();
 		try
 		{
 			try
 			{
-				writeChunk();
+				writeChunk(chunk, off, len);
 			}
 			catch (SQLException e)
 			{
@@ -237,52 +177,37 @@
 		}
 	}
 
-	void populate(InputStream is, int length) throws SQLException
+	
+	void writeChunk(byte[] chunk, int off, int len) throws SQLException
+	{
+		writeChunk(conn_.server_, conn_.getDialogueId(), conn_.getTxid(),
+				lob_.lobLocator_, chunk, off, len, startingPos_-1+off);
+	}
+
+	void populate(InputStream is, long length) throws SQLException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_populate].methodEntry();
 		try
 		{
 			int tempLen;
-			int readLen;
+			long readLen;
 			int retLen=0;
 				
 			readLen = length;
 			try
 			{
-				while (readLen > 0)
+				while (true)
 				{
 					if (readLen <= lob_.chunkSize_)
-						tempLen = readLen;
+						tempLen = (int)readLen;
 					else
 						tempLen = lob_.chunkSize_;
 					retLen = is.read(chunk_, 0, tempLen);
-					if (retLen == -1)
+					if (retLen == -1 || (length != 0 && readLen == 0))
 						break;
-					currentByte_ = retLen;
-
-					if ((traceWriter_ != null) && 
-						((traceFlag_ == T2Driver.LOB_LVL) || (traceFlag_ == T2Driver.ENTRY_LVL)))
-					{
-						// For tracing, only print the 1st and last LOB data chunk write info to limit 
-						// potential overflow of buffer for trace output.
-						if (readLen==length) 			// 1st writeChunk
-						{
-							traceWriter_.println(getTraceId()
-								+ "populate() -  First writeChunk data: tableName_=" + lob_.tableName_
-								+ " dataLocator_=" + lob_.dataLocator_ + " length=" + length 
-								+ " currentChunkNo_=" + currentChunkNo_ + " updChunkNo_=" + updChunkNo_ + " retLen=" + retLen);
-						}
-						if (readLen<=lob_.chunkSize_)	// last writeChunk (NOTE: last chunk can be exactly chunkSize_)
-						{
-							traceWriter_.println(getTraceId()
-								+ "populate() -  Last writeChunk data: tableName_=" + lob_.tableName_
-								+ " dataLocator_=" + lob_.dataLocator_ + " length=" + length 
-								+ " currentChunkNo_=" + currentChunkNo_ + " updChunkNo_=" + updChunkNo_ + " retLen=" + retLen);
-						}
-					}
-
-					writeChunk();
-					readLen -= retLen;
+					writeChunk(chunk_, 0, retLen);
+					if (length > 0)
+						readLen -= retLen;
 				}
 			}
 			catch (IOException e)
@@ -300,7 +225,7 @@
 	}
 
 	// constructors
-	SQLMXLobOutputStream(SQLMXConnection connection, SQLMXLob lob, long pos) throws 
+	SQLMXLobOutputStream(SQLMXConnection connection, long startingPos, SQLMXLob lob) throws 
 		SQLException
 	{
 		if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLobOutputStream].methodEntry();
@@ -311,43 +236,18 @@
 			lob_ = lob;
 			length = lob_.length();
 			conn_ = connection;
-			if (pos < 1 || pos > length+1)
-				throw Messages.createSQLException(conn_.locale_,"invalid_position_value", null);
-			startingPos_ = pos;
 			chunk_ = new byte[lob_.chunkSize_];
 			isFlushed_ = false;
-			if (length == 0)
-				updChunkNo_ = -1;
-			else
-			{
-				if ((length % lob_.chunkSize_) == 0)
-					updChunkNo_ = (int)(length / lob_.chunkSize_)-1;
-				else
-					updChunkNo_ = (int)(length / lob_.chunkSize_);
-			}
-			currentChunkNo_ = (int)((pos-1)/ lob_.chunkSize_);
-			currentByte_ = (int)((pos-1) % lob_.chunkSize_);
-			updOffset_ = (int)((pos-1) % lob_.chunkSize_);
-
+			startingPos_ = startingPos;
 			traceWriter_ = SQLMXDataSource.traceWriter_;
-			
-			// Build up template portion of jdbcTrace output. Pre-appended to jdbcTrace entries.
-			// jdbcTrace:[XXXX]:[Thread[X,X,X]]:[XXXXXXXX]:ClassName.
-			if (traceWriter_ != null) 
-			{
-				traceFlag_ = T2Driver.traceFlag_;
-				String className = getClass().getName();
-				setTraceId(T2Driver.traceText + T2Driver.dateFormat.format(new Date()) 
-					+ "]:[" + Thread.currentThread() + "]:[" + hashCode() +  "]:" 
-					+ className.substring(T2Driver.REMOVE_PKG_NAME,className.length()) 
-					+ ".");
-			}
+			currentByte_ = 0;
 		}
 		finally
 		{
 			if (JdbcDebugCfg.entryActive) debug[methodId_SQLMXLobOutputStream].methodExit();
 		}
 	}
+
 	public void setTraceId(String traceId_) {
 		this.traceId_ = traceId_;
 	}
@@ -356,19 +256,19 @@
 		return traceId_;
 	}
 	// Fields
-	private String				traceId_;
-	static PrintWriter	traceWriter_;
+	private String			traceId_;
+	static PrintWriter		traceWriter_;
 	static int			traceFlag_;
 	SQLMXLob			lob_;
 	long				startingPos_;
-	SQLMXConnection		conn_;
+	SQLMXConnection			conn_;
 	boolean				isClosed_;
 	byte[]				chunk_;
-	int					currentByte_;
-	int					currentChunkNo_;
+	int				currentByte_;
+	int				currentChunkNo_;
 	boolean				isFlushed_;
-	int					updChunkNo_;
-	int					updOffset_;
+	int				updChunkNo_;
+	int				updOffset_;
 
 	private static int methodId_close					= 0;
 	private static int methodId_flush					= 1;
@@ -399,4 +299,5 @@
 			debug[methodId_SQLMXLobOutputStream] = new JdbcDebug(className,"SQLMXLobOutputStream");
 		}
 	}
+	native void writeChunk(String server, long dialogueId, long txid, String lobLocator, byte[] chunk, int off, int writeLength, long pos);
 }
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java
index 6975932..8a2667a 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPooledConnection.java
@@ -215,7 +215,7 @@
 			}
 			listenerList_ = new LinkedList<ConnectionEventListener>();
 			connection_ = new SQLMXConnection(this, info);
-			refToDialogueId_.put(connection_.pRef_, new Long(connection_.getDialogueId_()));
+			refToDialogueId_.put(connection_.pRef_, new Long(connection_.getDialogueId()));
 		}
 		finally
 		{
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java
index e7fd377..10f4643 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXPreparedStatement.java
@@ -251,7 +251,7 @@
 			paramRowCount_++;
 			paramContainer_ = new DataWrapper(inputDesc_.length);
 			if (isAnyLob_ && (lobObjects_ == null))
-				lobObjects_ = new ArrayList<Object>();
+				lobObjects_ = new ArrayList<SQLMXLob>();
 			// Clear the isValueSet_ flag in inputDesc_ and add the lob objects
 			// to the lobObject List
 			for (int i = 0; i < inputDesc_.length; i++) {
@@ -261,7 +261,9 @@
 				// not
 				// be null, based on the number of LOB columns in the query
 				if (inputDesc_[i].paramValue_ != null) {
+/* Todo Selva
 					lobObjects_.add(inputDesc_[i].paramValue_);
+*/
 					inputDesc_[i].paramValue_ = null;
 				}
 				inputDesc_[i].isValueSet_ = false;
@@ -366,7 +368,7 @@
 									resultSet_.close(true);
 								else{
 									close(connection_.server_,
-											connection_.getDialogueId_(), stmtId_,
+											connection_.getDialogueId(), stmtId_,
 											true);
 									connection_.hClosestmtCount++;
 
@@ -384,7 +386,7 @@
 								}
 							} else{
 								close(connection_.server_,
-										connection_.getDialogueId_(), stmtId_, true);
+										connection_.getDialogueId(), stmtId_, true);
 								connection_.hClosestmtCount++;
 
 								if (connection_.out_ != null) {
@@ -473,7 +475,7 @@
 			int currentTxid = 0;
 			// Reset current txn ID at end if internal txn used for autocommit
 			// duties
-
+			Object[] lobObjects;
 			validateExecuteInvocation();
 			try {
 				synchronized (connection_) {
@@ -504,28 +506,41 @@
 /* Linux port - ToDo tmf.jar related
 					if (isAnyLob_ && (txnState == Current.StatusNoTransaction)
 							&& (connection_.autoCommit_)) {
-						currentTxid = connection_.getTxid_();
+						currentTxid = connection_.getTxid();
 						connection_.setTxid_(0);
 						tx.begin();
 						txBegin = true;
 						connection_.autoCommit_ = false;
 					}
 */
+					long beginTime=0,endTime,timeTaken;
+					if (connection_.t2props.getQueryExecuteTime() > 0)
+						beginTime=System.currentTimeMillis();
+					boolean currentAC = connection_.autoCommit_;
+					if (isAnyLob_) {
+						if (outputDesc_ != null)
+							throw Messages.createSQLException(connection_.locale_, "lob_as_param_not_support", 
+								null);
+						else {
+							try {
+								lobLocators_ = getLobLocators();
+								setLobLocators();
+							}	
+							finally {
+							}
+						}
+					}	
+					else {
 					// Allocate the result set incase any rows are returned by
 					// the execute
-					if (outputDesc_ != null)
-						resultSet_ = new SQLMXResultSet(this, outputDesc_);
-					else
-						resultSet_ = null;
-					long beginTime=0,endTime,timeTaken;
-//					if ((T2Driver.queryExecuteTime_ > 0) || (SQLMXDataSource.queryExecuteTime_> 0) ) {
-					if(connection_.t2props.getQueryExecuteTime() > 0){
-						beginTime=System.currentTimeMillis();
-					}
+						if (outputDesc_ != null)
+							resultSet_ = new SQLMXResultSet(this, outputDesc_);
+						else
+							resultSet_ = null;
 
-					if (inputDesc_ != null) {
-						execute(connection_.server_, connection_.getDialogueId_(),
-								connection_.getTxid_(),
+						if (inputDesc_ != null) {
+							execute(connection_.server_, connection_.getDialogueId(),
+								connection_.getTxid(),
 								connection_.autoCommit_,
 								connection_.transactionMode_, stmtId_,
 								cursorName_, isSelect_, paramRowCount_ + 1,
@@ -533,94 +548,34 @@
 								queryTimeout_, isAnyLob_,
 								connection_.iso88591EncodingOverride_,
 								resultSet_, false);
-					} else {
-						execute(connection_.server_, connection_.getDialogueId_(),
-								connection_.getTxid_(),
+						} else {
+							execute(connection_.server_, connection_.getDialogueId(),
+								connection_.getTxid(),
 								connection_.autoCommit_,
 								connection_.transactionMode_, stmtId_,
 								cursorName_, isSelect_, paramRowCount_ + 1, 0,
 								null, queryTimeout_, isAnyLob_,
 								connection_.iso88591EncodingOverride_,
 								resultSet_, false);
+						}
 					}
-
-//					if ((T2Driver.queryExecuteTime_ > 0) || (SQLMXDataSource.queryExecuteTime_> 0) ) {
-					if(connection_.t2props.getQueryExecuteTime() > 0){
+					if (isAnyLob_)
+						populateLobObjects();
+					if (connection_.t2props.getQueryExecuteTime() > 0) {
 						endTime = System.currentTimeMillis();
 						timeTaken = endTime - beginTime;
 						printQueryExecuteTimeTrace(timeTaken);
 					}
 
-					if (resultSet_ != null) {
+					if (resultSet_ != null) 
 						ret = true;
-					} else {
-						if (isAnyLob_)
-							populateLobObjects();
-					}
-					//**********************************************************
-					// *****************
-					// * If LOB is involved with AutoCommit enabled an no
-					// external Txn,
-					// * commit transaction and re-enable autocommit
-					//**********************************************************
-					// *****************
-					if (txBegin) {
-						connection_.autoCommit_ = true;
-/* Linux port - ToDo tmf.jar related
-						tx.commit(false);
-*/
-						txBegin = false;
-					}
-				}// End sync
-			}
-/* Linux port - ToDo tmf.jar related
-			catch (com.tandem.util.FSException fe1) {
-				SQLException se1 = null;
-				SQLException se2 = null;
-
-				Object[] messageArguments1 = new Object[2];
-				messageArguments1[0] = Short.toString(fe1.error);
-				messageArguments1[1] = fe1.getMessage();
-				se1 = Messages.createSQLException(connection_.locale_,
-						"transaction_error_update", messageArguments1);
-
-				try {
-					if (txBegin)
-						tx.rollback();
-				} catch (com.tandem.util.FSException fe2) {
-					Object[] messageArguments2 = new Object[2];
-					messageArguments2[0] = Short.toString(fe2.error);
-					messageArguments2[1] = fe2.getMessage();
-					se2 = Messages.createSQLException(connection_.locale_,
-							"transaction_error_update", messageArguments2);
-					se2.setNextException(se1);
-					throw se2;
 				}
-
-				throw se1;
-			}
-*/
-			catch (SQLException se) {
-				SQLException se2 = null;
-/* Linux port - ToDo tmf.jar related
-				try {
-					if (txBegin)
-						tx.rollback();
-				} catch (com.tandem.util.FSException fe2) {
-					Object[] messageArguments = new Object[2];
-					messageArguments[0] = Short.toString(fe2.error);
-					messageArguments[1] = fe2.getMessage();
-					se2 = Messages.createSQLException(connection_.locale_,
-							"transaction_error_update", messageArguments);
-					se2.setNextException(se);
-					throw se2;
-				}
-*/
-				throw se;
 			} finally {
+/*
 				if (currentTxid != 0) {
 					connection_.setTxid_(currentTxid);
 				}
+*/
 			}
 
 			return ret;
@@ -705,7 +660,7 @@
 					// * If LOB is involved with autocommit enabled an no
 					// external Txn, we must
 					// * perform the base table (execute) and LOB table
-					// (populateBatchLobObjects)
+					// (populateLobObjects)
 					// * updates/inserts as a single unit of work (data
 					// integrity issue).
 					// * These updates/inserts will be performed inside an
@@ -722,7 +677,7 @@
 /* Linux port - ToDo tmf.jar related
 					if (isAnyLob_ && (txnState == Current.StatusNoTransaction)
 							&& (connection_.autoCommit_)) {
-						currentTxid = connection_.getTxid_();
+						currentTxid = connection_.getTxid();
 						connection_.setTxid_(0);
 						tx.begin();
 						txBegin = true;
@@ -746,8 +701,8 @@
 					beginTime=System.currentTimeMillis();
 					}
 
-					execute(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					execute(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, stmtId_, cursorName_,
 							isSelect_, paramRowCount_, inputDesc_.length,
 							getParameters(), queryTimeout_,
@@ -764,7 +719,7 @@
 						printQueryExecuteTimeTrace(timeTaken);
 					}
 
-					populateBatchLobObjects();
+					populateLobObjects();
 					//**********************************************************
 					// *****************
 					// * If LOB is involved with AutoCommit enabled an no
@@ -901,16 +856,16 @@
 			}
 			synchronized (connection_) {
 				if (inputDesc_ != null) {
-					execute(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					execute(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, stmtId_, cursorName_,
 							isSelect_, paramRowCount_ + 1, inputDesc_.length,
 							getParameters(), queryTimeout_, isAnyLob_,
 							connection_.iso88591EncodingOverride_, resultSet_,
 							false);
 				} else {
-					execute(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					execute(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, stmtId_, cursorName_,
 							isSelect_, paramRowCount_ + 1, 0, null,
 							queryTimeout_, isAnyLob_,
@@ -1008,7 +963,7 @@
 						if (isAnyLob_
 								&& (txnState == Current.StatusNoTransaction)
 								&& (connection_.autoCommit_)) {
-							currentTxid = connection_.getTxid_();
+							currentTxid = connection_.getTxid();
 							connection_.setTxid_(0);
 
 							tx.begin();
@@ -1022,8 +977,8 @@
 						if(connection_.t2props.getQueryExecuteTime() > 0){
 						beginTime=System.currentTimeMillis();
 						}
-						execute(connection_.server_, connection_.getDialogueId_(),
-								connection_.getTxid_(),
+						execute(connection_.server_, connection_.getDialogueId(),
+								connection_.getTxid(),
 								connection_.autoCommit_,
 								connection_.transactionMode_, stmtId_,
 								cursorName_, isSelect_, paramRowCount_ + 1,
@@ -1116,8 +1071,8 @@
 					if(connection_.t2props.getQueryExecuteTime() > 0){
 					beginTime=System.currentTimeMillis();
 					}
-					execute(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					execute(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, stmtId_, cursorName_,
 							isSelect_, paramRowCount_ + 1, 0, null,
 							queryTimeout_, isAnyLob_,
@@ -1177,24 +1132,6 @@
 		}
 	}
 
-	/**
-	 * Sets the designated parameter to the given <tt>Array</tt> object. The
-	 * driver converts this to an SQL <tt>ARRAY</tt> value when it sends it to
-	 * the database.
-	 * <p>
-	 * <B>Note:</B>This method is <em><B>unsupported</B></em> by the Trafodion JDBC
-	 * driver. If this method is called a <i>Unsupported feature -
-	 * {setArray())</i> SQLException will be thrown.
-	 * </p>
-	 *
-	 * @param i
-	 *            the first parameter is 1, the second is 2, ...
-	 * @param x
-	 *            an object representing an SQL array
-	 *
-	 * @throws SQLException
-	 *             Unsupported feature.
-	 */
 	public void setArray(int parameterIndex, Array x) throws SQLException {
 		if (JdbcDebugCfg.entryActive)
 			debug[methodId_setArray].methodEntry();
@@ -1208,38 +1145,6 @@
 		}
 	}
 
-	/**
-	 * Sets the designated parameter to the given input stream, which will have
-	 * the specified number of bytes. When a very large ASCII value is input to
-	 * a <tt>LONGVARCHAR</tt> parameter, it may be more practical to send it via
-	 * a <tt>java.io.InputStream</tt>. Data will be read from the stream as
-	 * needed until end-of-file is reached. The JDBC driver will do any
-	 * necessary conversion from ASCII to the database char format.
-	 * <P>
-	 * <B>Note:</B> This stream object can either be a standard Java stream
-	 * object or your own subclass that implements the standard interface.
-	 * </p>
-	 * <p>
-	 * This API call <em><B>can only</B></em> be used to read into a SQL column
-	 * type <tt>CLOB</tt>, <tt>CHAR</tt>, <tt>VARCHAR</tt>, <tt>LONVARCHAR</tt>,
-	 * <tt>BINARY</tt>, <tt>VARBINARY</tt>, or <tt>LONGVARBINARY</tt>.
-	 *
-	 * @param parameterIndex
-	 *            the first parameter is 1...
-	 * @param x
-	 *            the Java input stream that contains the ASCII parameter value
-	 * @param length
-	 *            the number of bytes in the stream
-	 *
-	 * @exception SQLException
-	 *                restricted data type
-	 * @exception SQLException
-	 *                unsupported encoding
-	 * @exception SQLException
-	 *                I/O error
-	 * @exception SQLException
-	 *                invalid data type for column
-	 */
 	public void setAsciiStream(int parameterIndex, InputStream x, int length)
 			throws SQLException {
 		if (JdbcDebugCfg.entryActive)
@@ -1247,37 +1152,35 @@
 		try {
 			byte[] buffer;
 			int dataType;
-			long dataLocator;
 
 			validateSetInvocation(parameterIndex);
 			dataType = inputDesc_[parameterIndex - 1].dataType_;
 
-			if (x == null) {
-				paramContainer_.setNull(parameterIndex);
-			} else {
-				switch (dataType) {
-				case Types.CLOB:
-					dataLocator = connection_.getDataLocator(
-							connection_.clobTableName_, false);
-					SQLMXClob clob = new SQLMXClob(connection_,
-							inputDesc_[parameterIndex - 1].tableName_,
-							dataLocator, x, length);
-					inputDesc_[parameterIndex - 1].paramValue_ = clob;
-					isAnyLob_ = true;
-					paramContainer_.setLong(parameterIndex, dataLocator);
-					break;
-				case Types.BLOB:
-					throw Messages.createSQLException(connection_.locale_,
-							"restricted_data_type", null);
-				case Types.CHAR:
-				case Types.VARCHAR:
-				case Types.LONGVARCHAR:
-				case Types.BINARY: // At this time SQL/MX does not have this
-					// column data type
-				case Types.VARBINARY: // At this time SQL/MX does not have this
-					// column data type
-				case Types.LONGVARBINARY: // At this time SQL/MX does not have
-					// this column data type
+			switch (dataType) {
+			case Types.CLOB:
+				SQLMXClob clob = null;
+				isAnyLob_ = true;
+				if (x == null) 
+					paramContainer_.setNull(parameterIndex);
+				else {
+					clob = new SQLMXClob(connection_, null, x, length);
+					inputDesc_[parameterIndex - 1].paramValue_ = "";
+					paramContainer_.setString(parameterIndex, "");
+				}
+				addLobObjects(parameterIndex, clob);
+				break;
+			case Types.BLOB:
+				throw Messages.createSQLException(connection_.locale_,
+						"restricted_data_type", null);
+			case Types.CHAR:
+			case Types.VARCHAR:
+			case Types.LONGVARCHAR:
+			case Types.BINARY: // At this time SQL/MX does not have this column data type
+			case Types.VARBINARY: // At this time SQL/MX does not have this column data type
+			case Types.LONGVARBINARY: // At this time SQL/MX does not have this column data type
+				if (x == null) 
+					paramContainer_.setNull(parameterIndex);
+				else {
 					buffer = new byte[length];
 					try {
 						x.read(buffer);
@@ -1296,11 +1199,11 @@
 						throw Messages.createSQLException(connection_.locale_,
 								"unsupported_encoding", messageArguments);
 					}
-					break;
-				default:
-					throw Messages.createSQLException(connection_.locale_,
-							"invalid_datatype_for_column", null);
 				}
+				break;
+			default:
+				throw Messages.createSQLException(connection_.locale_,
+							"invalid_datatype_for_column", null);
 			}
 			inputDesc_[parameterIndex - 1].isValueSet_ = true;
 		} finally {
@@ -1309,49 +1212,6 @@
 		}
 	}
 
-	/**
-	 * Sets the designated parameter to the given <tt>java.math.BigDecimal</tt>
-	 * value. The driver converts this to a SQL <tt>NUMERIC</tt> value when it
-	 * sends it to the database.
-	 * <p>
-	 * <B>Note:</B> An <em>extended</em> feature of the Trafodion JDBC driver will
-	 * allow the setBigDecimal to write data to any compatible SQL column type.
-	 * The given <tt>java.math.BigDecimal</tt> value is converted to the correct
-	 * SQL column type, before the data is written to the database. If the
-	 * conversion can not be performed, then the SQLException
-	 * "conversion not allowed" will be thrown.
-	 * </p>
-	 * <p>
-	 * The compatible SQL column types are:
-	 *
-	 * <ul PLAIN> <tt>TINYINT</tt> </ul> <ul PLAIN> <tt>SMALLINT</tt> </ul> <ul
-	 * PLAIN> <tt>INTEGER</tt> </ul> <ul PLAIN> <tt>BIGINT</tt> </ul> <ul PLAIN>
-	 * <tt>REAL</tt> </ul> <ul PLAIN> <tt>DOUBLE</tt> </ul> <ul PLAIN>
-	 * <tt>DECIMAL</tt> </ul> <ul PLAIN> <tt>NUMERIC</tt> </ul> <ul PLAIN>
-	 * <tt>BOOLEAN</tt> </ul> <ul PLAIN> <tt>CHAR</tt> </ul> <ul PLAIN>
-	 * <tt>VARCHAR</tt> </ul> <ul PLAIN> <tt>LONGVARCHAR</tt> </ul>
-	 * </p>
-	 * <p>
-	 * A non-compatible SQL column type will result in a <i>Java data type does
-	 * not match SQL data type for column</i> SQLException being thrown.
-	 *
-	 * @param parameterIndex
-	 *            the first parameter is 1...
-	 * @param x
-	 *            the parameter value
-	 *
-	 * @exception SQLException
-	 *                wrong data type for the column
-	 * @exception SQLException
-	 *                the scale value was negative
-	 * @exception SQLException
-	 *                the data is out of range(value was too big or small for
-	 *                the column)
-	 * @exception SQLException
-	 *                writing a negative value to an unsigned column
-	 * @warning SQLWarning that the data value was rounded up
-	 *
-	 */
 	public void setBigDecimal(int parameterIndex, BigDecimal x)
 			throws SQLException {
 		/*
@@ -1681,40 +1541,41 @@
 		try {
 			byte[] buffer;
 			int dataType;
-			long dataLocator;
 
 			validateSetInvocation(parameterIndex);
 			dataType = inputDesc_[parameterIndex - 1].dataType_;
 
-			if (x == null) {
-				paramContainer_.setNull(parameterIndex);
-			} else {
-				switch (dataType) {
-				case Types.CLOB:
-					throw Messages.createSQLException(connection_.locale_,
-							"restricted_data_type", null);
-				case Types.BLOB:
-					dataLocator = connection_.getDataLocator(
-							connection_.blobTableName_, true);
-					SQLMXBlob blob = new SQLMXBlob(connection_,
-							inputDesc_[parameterIndex - 1].tableName_,
-							dataLocator, x, length);
-					isAnyLob_ = true;
-					inputDesc_[parameterIndex - 1].paramValue_ = blob;
-					isAnyLob_ = true;
-					paramContainer_.setLong(parameterIndex, dataLocator);
-					break;
-				case Types.DOUBLE:
-				case Types.DECIMAL:
-				case Types.NUMERIC:
-				case Types.FLOAT:
-				case Types.BIGINT:
-				case Types.INTEGER:
-				case Types.SMALLINT:
-				case Types.TINYINT:
-					throw Messages.createSQLException(connection_.locale_,
+			switch (dataType) {
+			case Types.CLOB:
+				throw Messages.createSQLException(connection_.locale_,
+						"restricted_data_type", null);
+			case Types.BLOB:
+				SQLMXBlob blob = null;
+				isAnyLob_ = true;
+				if (x == null) 
+					paramContainer_.setNull(parameterIndex);
+				else {
+					blob = new SQLMXBlob(connection_, null, x, length);
+					inputDesc_[parameterIndex - 1].paramValue_ = "";
+					paramContainer_.setString(parameterIndex, "");
+				}
+				addLobObjects(parameterIndex, blob);
+				break;
+			case Types.DOUBLE:
+			case Types.DECIMAL:
+			case Types.NUMERIC:
+			case Types.FLOAT:
+			case Types.BIGINT:
+			case Types.INTEGER:
+			case Types.SMALLINT:
+			case Types.TINYINT:
+				throw Messages.createSQLException(connection_.locale_,
 							"invalid_datatype_for_column", null);
-				default:
+			default:
+				if (x == null) { 
+					paramContainer_.setNull(parameterIndex);
+				}
+				else {
 					buffer = new byte[length];
 
 					try {
@@ -1757,25 +1618,21 @@
 					.toString(parameterIndex)
 					+ ",?");
 		try {
-			int dataType;
-			long dataLocator;
-			if (x == null) {
-				setNull(parameterIndex, java.sql.Types.BLOB);
-				return;
-			}
-
 			validateSetInvocation(parameterIndex);
+			int dataType = inputDesc_[parameterIndex - 1].dataType_;
 			dataType = inputDesc_[parameterIndex - 1].dataType_;
 			switch (dataType) {
 			case Types.BLOB:
-				dataLocator = connection_.getDataLocator(
-						connection_.blobTableName_, true);
-				SQLMXBlob blob = new SQLMXBlob(connection_,
-						inputDesc_[parameterIndex - 1].tableName_, dataLocator,
-						x);
-				inputDesc_[parameterIndex - 1].paramValue_ = blob;
+				SQLMXBlob blob = null;
 				isAnyLob_ = true;
-				paramContainer_.setLong(parameterIndex, dataLocator);
+				if (x == null) 
+					setNull(parameterIndex, Types.BLOB);
+				else {
+					blob = new SQLMXBlob(connection_, null, x);
+					inputDesc_[parameterIndex - 1].paramValue_ = "";
+					paramContainer_.setString(parameterIndex, "");
+				}
+				addLobObjects(parameterIndex, blob);
 				break;
 			default:
 				throw Messages.createSQLException(connection_.locale_,
@@ -1946,46 +1803,41 @@
 					.toString(parameterIndex)
 					+ ",byte[]");
 		try {
-			int dataType;
+			validateSetInvocation(parameterIndex);
+			int dataType = inputDesc_[parameterIndex - 1].dataType_;
+            		int dataCharSet = inputDesc_[parameterIndex - 1].sqlCharset_;
 
-			if (x == null) {
+			if (x == null && dataType != Types.CLOB && dataType != Types.BLOB) {
 				setNull(parameterIndex, java.sql.Types.LONGVARBINARY);
-				return;
 			}
 
-
-			//byte[] tmpArray = new byte[x.length];
-			//System.arraycopy(x, 0, tmpArray, 0, x.length);
-
-			validateSetInvocation(parameterIndex);
-			dataType = inputDesc_[parameterIndex - 1].dataType_;
-            int dataCharSet = inputDesc_[parameterIndex - 1].sqlCharset_;
 			switch (dataType) {
 			case Types.BLOB:
-				long dataLocator = connection_.getDataLocator(
-						connection_.blobTableName_, true);
-				SQLMXBlob blob = new SQLMXBlob(connection_,
-						inputDesc_[parameterIndex - 1].tableName_, dataLocator,
-						x);
-				inputDesc_[parameterIndex - 1].paramValue_ = blob;
+				SQLMXBlob blob = null;
 				isAnyLob_ = true;
-				paramContainer_.setLong(parameterIndex, dataLocator);
+				if (x == null) 
+					paramContainer_.setNull(parameterIndex);
+				else {
+					blob = new SQLMXBlob(connection_, null, x);
+					inputDesc_[parameterIndex - 1].paramValue_ = "";
+					paramContainer_.setString(parameterIndex, "");
+				}
+				addLobObjects(parameterIndex, blob);
 				break;
-            case Types.CHAR:
-            case Types.VARCHAR:
-            case Types.LONGVARCHAR:
-                String charSet = SQLMXDesc.SQLCHARSETSTRING_ISO88591;
-                if (dataCharSet == SQLMXDesc.SQLCHARSETCODE_UCS2)
-                    charSet = "UTF-16LE";
-                try {
-                    x = (new String(x)).getBytes(charSet);
-                } catch (UnsupportedEncodingException e) {
-                    e.printStackTrace();
-                    throw Messages.createSQLException(connection_.locale_, "unsupported_encoding",
-                            new Object[] { charSet });
-                }
-                paramContainer_.setObject(parameterIndex, x);
-                break;
+			case Types.CHAR:
+			case Types.VARCHAR:
+			case Types.LONGVARCHAR:
+				String charSet = SQLMXDesc.SQLCHARSETSTRING_ISO88591;
+				if (dataCharSet == SQLMXDesc.SQLCHARSETCODE_UCS2)
+					charSet = "UTF-16LE";
+				try {
+					x = (new String(x)).getBytes(charSet);
+				} catch (UnsupportedEncodingException e) {
+					throw Messages.createSQLException(connection_.locale_, "unsupported_encoding",
+						new Object[] { charSet });
+				}
+				paramContainer_.setObject(parameterIndex, x);
+				break;
 			case Types.DATE:
 			case Types.TIME:
 			case Types.TIMESTAMP:
@@ -2055,34 +1907,37 @@
 			validateSetInvocation(parameterIndex);
 			dataType = inputDesc_[parameterIndex - 1].dataType_;
 
-			if (reader == null) {
-				paramContainer_.setNull(parameterIndex);
-			} else {
-				switch (dataType) {
-				case Types.CLOB:
-					long dataLocator = connection_.getDataLocator(
-							connection_.clobTableName_, false);
-					SQLMXClob clob = new SQLMXClob(connection_,
-							inputDesc_[parameterIndex - 1].tableName_,
-							dataLocator, reader, length);
-					inputDesc_[parameterIndex - 1].paramValue_ = clob;
-					isAnyLob_ = true;
-					paramContainer_.setLong(parameterIndex, dataLocator);
-					break;
-				case Types.BLOB:
-					throw Messages.createSQLException(connection_.locale_,
+			switch (dataType) {
+			case Types.CLOB:
+				SQLMXClob clob = null;
+				isAnyLob_ = true;
+				if (reader == null) 
+					paramContainer_.setNull(parameterIndex);
+				else {
+					clob = new SQLMXClob(connection_, null, reader, length);
+					inputDesc_[parameterIndex - 1].paramValue_ = "";
+					paramContainer_.setString(parameterIndex, "");
+				}
+				addLobObjects(parameterIndex, clob);
+				break;
+			case Types.BLOB:
+				throw Messages.createSQLException(connection_.locale_,
 							"restricted_data_type", null);
-				case Types.DECIMAL:
-				case Types.DOUBLE:
-				case Types.FLOAT:
-				case Types.NUMERIC:
-				case Types.BIGINT:
-				case Types.INTEGER:
-				case Types.SMALLINT:
-				case Types.TINYINT:
-					throw Messages.createSQLException(connection_.locale_,
+			case Types.DECIMAL:
+			case Types.DOUBLE:
+			case Types.FLOAT:
+			case Types.NUMERIC:
+			case Types.BIGINT:
+			case Types.INTEGER:
+			case Types.SMALLINT:
+			case Types.TINYINT:
+				throw Messages.createSQLException(connection_.locale_,
 							"invalid_datatype_for_column", null);
-				default:
+			default:
+				if (reader == null) 
+					paramContainer_.setNull(parameterIndex);
+				else {
+				
 					buffer = new char[length];
 					try {
 						reader.read(buffer);
@@ -2124,27 +1979,20 @@
 					.toString(parameterIndex)
 					+ ",?");
 		try {
-			int dataType;
-			long dataLocator;
-
-			if (x == null) {
-				setNull(parameterIndex, Types.CLOB);
-				return;
-			}
-
-
 			validateSetInvocation(parameterIndex);
-			dataType = inputDesc_[parameterIndex - 1].dataType_;
+			int dataType = inputDesc_[parameterIndex - 1].dataType_;
 			switch (dataType) {
 			case Types.CLOB:
-				dataLocator = connection_.getDataLocator(
-						connection_.clobTableName_, false);
-				SQLMXClob clob = new SQLMXClob(connection_,
-						inputDesc_[parameterIndex - 1].tableName_, dataLocator,
-						x);
-				inputDesc_[parameterIndex - 1].paramValue_ = clob;
+				SQLMXClob clob = null;
 				isAnyLob_ = true;
-				paramContainer_.setLong(parameterIndex, dataLocator);
+				if (x == null) 
+					setNull(parameterIndex, Types.CLOB);
+				else {
+					clob = new SQLMXClob(connection_, null, x);
+					inputDesc_[parameterIndex - 1].paramValue_ = "";
+					paramContainer_.setString(parameterIndex, "");
+				}
+				addLobObjects(parameterIndex, clob);
 				break;
 			case Types.DECIMAL:
 			case Types.DOUBLE:
@@ -2500,7 +2348,7 @@
 
 				synchronized (connection_) {
 					// Pass the fetch size change to the driver
-					resetFetchSize(connection_.getDialogueId_(), stmtId_, fetchSize_);
+					resetFetchSize(connection_.getDialogueId(), stmtId_, fetchSize_);
 				}
 			}
 		} finally {
@@ -4164,15 +4012,12 @@
 					.toString(parameterIndex)
 					+ "," + x);
 		try {
-			long dataLocator;
-
 			validateSetInvocation(parameterIndex);
+			int dataType = inputDesc_[parameterIndex - 1].dataType_;
 
-			if (x == null) {
+			if (x == null && dataType != Types.CLOB && dataType != Types.BLOB) {
 				setNull(parameterIndex, Types.NULL);
 			} else {
-				int dataType = inputDesc_[parameterIndex - 1].dataType_;
-
 				switch (dataType) {
 				case Types.CHAR:
 				case Types.VARCHAR:
@@ -4205,14 +4050,16 @@
 					break;
 				case Types.CLOB: // WLS extension: CLOB should to be able to
 					// write to string, deviation from API.
-					dataLocator = connection_.getDataLocator(
-							connection_.clobTableName_, false);
-					SQLMXClob clob = new SQLMXClob(connection_,
-							inputDesc_[parameterIndex - 1].tableName_,
-							dataLocator, x);
-					inputDesc_[parameterIndex - 1].paramValue_ = clob;
+					SQLMXClob clob = null;
 					isAnyLob_ = true;
-					paramContainer_.setLong(parameterIndex, dataLocator);
+					if (x == null) 
+						paramContainer_.setNull(parameterIndex);
+					else {
+						clob = new SQLMXClob(connection_, null, x);
+						inputDesc_[parameterIndex - 1].paramValue_ = "";
+						paramContainer_.setString(parameterIndex, "");
+					}
+					addLobObjects(parameterIndex, clob);
 					break;
 				case Types.ARRAY:
 				case Types.BINARY:
@@ -4811,6 +4658,15 @@
 		}
 	}
 
+	 void copyParameters(SQLMXPreparedStatement other) 
+	{
+		paramRowCount_ = other.paramRowCount_;
+		paramContainer_ = other.paramContainer_;
+		rowsValue_ = other.rowsValue_;
+		for (int paramNumber = 0; paramNumber < inputDesc_.length; paramNumber++)
+			inputDesc_[paramNumber].isValueSet_ = true;
+	}
+
 	void logicalClose() throws SQLException {
 		if (JdbcDebugCfg.entryActive)
 			debug[methodId_logicalClose].methodEntry();
@@ -4903,7 +4759,7 @@
 				}
 
 				// Check if the transaction is started by this Select statement
-				if (connection_.getTxid_() == 0 && txid != 0)
+				if (connection_.getTxid() == 0 && txid != 0)
 					resultSet_.txnStarted_ = true;
 				rowCount_ = -1;
 			} else {
@@ -5104,7 +4960,7 @@
 					return;
 				try {
 					if (hardClose){
-						close(connection_.server_, connection_.getDialogueId_(),
+						close(connection_.server_, connection_.getDialogueId(),
 								stmtId_, true);
 					connection_.hClosestmtCount++;
 
@@ -5137,29 +4993,6 @@
 		if (JdbcDebugCfg.entryActive)
 			debug[methodId_populateLobObjects].methodEntry();
 		try {
-			Object lob;
-
-			if (isAnyLob_) {
-				for (int i = 0; i < inputDesc_.length; i++) {
-					if (inputDesc_[i].paramValue_ != null) {
-						lob = inputDesc_[i].paramValue_;
-						if (lob instanceof SQLMXClob)
-							((SQLMXClob) lob).populate();
-						else
-							((SQLMXBlob) lob).populate();
-					}
-				}
-			}
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_populateLobObjects].methodExit();
-		}
-	}
-
-	void populateBatchLobObjects() throws SQLException {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_populateBatchLobObjects].methodEntry();
-		try {
 			int len;
 			Object lob;
 
@@ -5175,7 +5008,7 @@
 			}
 		} finally {
 			if (JdbcDebugCfg.entryActive)
-				debug[methodId_populateBatchLobObjects].methodExit();
+				debug[methodId_populateLobObjects].methodExit();
 		}
 	}
 //venu changed dialogueId from int to long for 64 bit
@@ -5233,8 +5066,8 @@
 				throw Messages.createSQLException(connection_.locale_,
 						"invalid_connection", null);
 			isSelect_ = getStmtSqlType(sql);
-			sql_ = scanSqlStr(sql).trim();
 			short stmtType = SQLMXConnection.getSqlStmtType(sql);
+			sql_ = sql;
 			this.setSqlType(stmtType);
 			if(stmtType == SQLMXConnection.TYPE_CONTROL){
 				isCQD = true;
@@ -5250,35 +5083,6 @@
 		}
 	}
 
-	SQLMXPreparedStatement(SQLMXConnection connection, String moduleName,
-			int moduleVersion, long moduleTimestamp, String stmtName,
-			boolean isSelect, int holdability) {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_SQLMXPreparedStatement_LLIJLZI].methodEntry();
-		try {
-			connection_ = connection;
-			moduleName_ = moduleName;
-			moduleVersion_ = moduleVersion;
-			moduleTimestamp_ = moduleTimestamp;
-			setStmtLabel_(stmtName);
-			isSelect_ = isSelect;
-
-			// Make Sure you initialize the other fields to the right value
-			fetchSize_ = SQLMXResultSet.DEFAULT_FETCH_SIZE;
-			maxRows_ = 0;
-			fetchDirection_ = ResultSet.FETCH_FORWARD;
-			queryTimeout_ = connection_.queryTimeout_;
-			resultSetType_ = ResultSet.TYPE_FORWARD_ONLY;
-			resultSetHoldability_ = holdability;
-			pRef_ = new WeakReference<SQLMXStatement>(this, connection_.refQ_);
-			batchBindingSize_ = connection.batchBindingSize_;
-			nf.setGroupingUsed(false);
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_SQLMXPreparedStatement_LLIJLZI].methodExit();
-		}
-	}
-
 	// native methods
 	native void prepare(String server, long dialogueId, int txid,
 			boolean autoCommit, String stmtLabel, String sql, boolean isSelect,
@@ -5310,7 +5114,11 @@
 	ArrayList<Object> rowsValue_;
 	DataWrapper paramContainer_;
 	boolean isAnyLob_;
-	ArrayList<Object> lobObjects_;
+	ArrayList<SQLMXLob> lobObjects_;
+	ArrayList<String> lobColNames_;
+	ArrayList<Integer> lobColIds_;
+	String[] lobLocators_;
+	boolean lobColDone_;
 
 	boolean isCQD;
 	short sqlType;
@@ -5442,7 +5250,6 @@
 	private static int methodId_reuse = 61;
 	private static int methodId_close = 62;
 	private static int methodId_populateLobObjects = 63;
-	private static int methodId_populateBatchLobObjects = 64;
 	private static int methodId_cpqPrepare = 65;
 	private static int methodId_SQLMXPreparedStatement_LLIII = 66;
 	private static int methodId_SQLMXPreparedStatement_LLIJLZI = 67;
@@ -5558,8 +5365,6 @@
 			debug[methodId_close] = new JdbcDebug(className, "close");
 			debug[methodId_populateLobObjects] = new JdbcDebug(className,
 					"populateLobObjects");
-			debug[methodId_populateBatchLobObjects] = new JdbcDebug(className,
-					"populateBatchLobObjects");
 			debug[methodId_cpqPrepare] = new JdbcDebug(className, "cpqPrepare");
 			debug[methodId_SQLMXPreparedStatement_LLIII] = new JdbcDebug(
 					className, "SQLMXPreparedStatement_LLIII");
@@ -5724,5 +5529,74 @@
     public String getInputDescName(int parameterIndex){
         return inputDesc_[parameterIndex].name_;
     }
+
+	private void addLobObjects(int parameterIndex, SQLMXLob x)
+	{
+		if (lobObjects_ == null) {
+			lobObjects_ = new ArrayList<SQLMXLob>();
+			lobColNames_ = new ArrayList<String>();
+			lobColIds_ = new ArrayList<Integer>();
+		}
+		if (! lobColDone_) {	
+			lobColNames_.add(getInputDescName(parameterIndex-1));
+			lobColIds_.add(parameterIndex);
+		}
+		lobObjects_.add(x);
+	}
+
+	private int getNumLobColumns() 
+	{
+		if (lobColNames_ == null)
+			return 0;
+		else
+			return lobColNames_.size();
+	}
+
+	private String getLobColumns() 
+	{
+		if (lobColNames_ == null)
+			return "";
+		StringBuilder colNames = new StringBuilder();
+		colNames.append(lobColNames_.get(0));
+		for (int i = 1; i < lobColNames_.size(); i++)
+			colNames.append(", ").append(lobColNames_.get(i));
+		return colNames.toString();
+	}
+
+	private void setLobLocators() throws SQLException 
+	{
+		if (lobLocators_.length != lobObjects_.size())
+			throw Messages.createSQLException(connection_.locale_, "lob_objects_and_locators_dont_match", null);
+		int lobLocatorIdx = 0;
+		for (SQLMXLob lobObject : lobObjects_) {
+			if (lobObject != null)
+				lobObject.setLobLocator(lobLocators_[lobLocatorIdx]);
+			lobLocatorIdx++;
+		}
+	}
+
+	private String[] getLobLocators() throws SQLException
+	{
+		//String selectForLobLocator = "select " + getLobColumns() + " from ( " + this.sql_ + " ) as x";
+		String selectForLobLocator = "select * from ( " + this.sql_ + " ) as x";
+		SQLMXPreparedStatement lobLocatorStmt = (SQLMXPreparedStatement)connection_.prepareStatement(selectForLobLocator);
+		lobLocatorStmt.copyParameters(this); 
+		SQLMXResultSet lobLocatorRS = (SQLMXResultSet)lobLocatorStmt.executeQuery();
+		int numLocators = ((paramRowCount_ == 0 ? paramRowCount_ = 1 : paramRowCount_) * getNumLobColumns());
+		String lobLocators[] = new String[numLocators];
+		int locatorsIdx = 0;
+		while (lobLocatorRS.next()) {
+			for (int i = 0; i < getNumLobColumns() ; i++) {
+				if (locatorsIdx < lobLocators.length)
+					//lobLocators[locatorsIdx++] = lobLocatorRS.getString(i+1);
+					lobLocators[locatorsIdx++] = lobLocatorRS.getLobLocator(lobColIds_.get(i));
+				else
+					throw Messages.createSQLException(connection_.locale_, 
+						"locators out of space" , null);
+			}	
+		}
+		return lobLocators;
+	}
+
 //------------------------------
 }
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXResultSet.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXResultSet.java
index 3ace978..0f4d853 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXResultSet.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXResultSet.java
@@ -604,7 +604,7 @@
 		try {
 			int dataType;
 			Object x;
-			long data_locator;
+			String data_locator;
 			Blob data;
 			String tableName;
 
@@ -621,10 +621,14 @@
 			else {
 				if (x instanceof Blob)
 					data = (Blob) x;
-				else if (x instanceof Long) {
-					data_locator = ((Long) x).longValue();
-					tableName = outputDesc_[columnIndex - 1].tableName_;
-					data = new SQLMXBlob(connection_, tableName, data_locator);
+				else if (x instanceof String) {
+					data_locator = (String)x; 
+					data = new SQLMXBlob(connection_, data_locator);
+					row.setBlob(columnIndex, data);
+					isAnyLob_ = true;
+				} else if (x instanceof byte[]) {
+					data_locator = new String((byte[])x);
+					data = new SQLMXBlob(connection_, data_locator);
 					row.setBlob(columnIndex, data);
 					isAnyLob_ = true;
 				} else
@@ -866,7 +870,7 @@
 			debug[methodId_getClob_I].methodEntry();
 		try {
 			int dataType;
-			long data_locator;
+			String  data_locator;
 			Clob data;
 			String tableName;
 
@@ -883,14 +887,19 @@
 			else {
 				if (x instanceof Clob)
 					data = (Clob) x;
-				else {
-					data_locator = row
-							.getLong(columnIndex, connection_.locale_);
-					tableName = outputDesc_[columnIndex - 1].tableName_;
-					data = new SQLMXClob(connection_, tableName, data_locator);
+				else if (x instanceof String) {
+					data_locator = (String) x;
+					data = new SQLMXClob(connection_, data_locator);
 					row.setObject(columnIndex, data);
 					isAnyLob_ = true;
-				}
+				} else if (x instanceof byte[]) {
+					data_locator = new String((byte[])x);
+					data = new SQLMXClob(connection_, data_locator);
+					row.setClob(columnIndex, data);
+					isAnyLob_ = true;
+				} else
+					throw Messages.createSQLException(connection_.locale_,
+							"restricted_data_type", null);
 			}
 			return data;
 		} finally {
@@ -1639,7 +1648,7 @@
 				// set name
 				charsetcode = outputDesc_[columnIndex - 1].sqlCharset_;
 				charsetname = SQLMXConnection.getCharsetEncodingCached(
-						connection_.server_, connection_.getDialogueId_(),
+						connection_.server_, connection_.getDialogueId(),
 						charsetcode, connection_.iso88591EncodingOverride_);
 				wasNull_ = false;
 				try {
@@ -1867,7 +1876,7 @@
 			}
 			// Context Handle and Statement ID
 			// Call to the C++ or JNI layer to retrieve ctxHandle and stmtID
-			getResultSetInfo(connection_.getDialogueId_(), stmtId_, retValue);
+			getResultSetInfo(connection_.getDialogueId(), stmtId_, retValue);
 			if (retValue.stmtClosed) {
 				retValue.RSClosed = retValue.stmtClosed;
 			}
@@ -2483,7 +2492,7 @@
 										"invalid_cursor_state", null);
 							}
 							validRow = fetchN(connection_.server_, connection_
-									.getDialogueId_(), connection_.getTxid_(),
+									.getDialogueId(), connection_.getTxid(),
 									connection_.transactionMode_, stmtId_,
 									maxRowCnt, queryTimeout, holdability_);
 						}// End sync
@@ -3588,15 +3597,15 @@
 							{
 								if ((stmt_.currentResultSetIndex_ == stmt_.resultSetIndex_)
 										&& (stmt_.spjRSCommitCount_ == 1)) {
-									txid = connection_.getTxid_();
+									txid = connection_.getTxid();
 									stmt_.spjRSCommitCount_--;
 								}
 							} else
-								txid = connection_.getTxid_();
+								txid = connection_.getTxid();
 						}
 						
 						close(connection_.server_,
-								connection_.getDialogueId_(), txid,
+								connection_.getDialogueId(), txid,
 								connection_.autoCommit_,
 								connection_.transactionMode_, stmtId_, dropStmt);
 
@@ -4230,7 +4239,7 @@
 			stmtId_ = stmtId;
 
 			// Check if the transaction is started by this Select statement
-			if (connection_.getTxid_() == 0 && txid != 0)
+			if (connection_.getTxid() == 0 && txid != 0)
 				txnStarted_ = true;
 			connection_.setTxid_(txid);
 			holdability_ = CLOSE_CURSORS_AT_COMMIT;
@@ -5104,5 +5113,33 @@
         row = (DataWrapper)cachedRows_.get(currentRow_ - 1);
         return row.getSQLBytes(columnIndex);
     }
+  
+    String getLobLocator(int columnIndex) throws SQLException 
+    {
+        Object x;
+        String data = null;
+
+        validateGetInvocation(columnIndex);
+        int dataType = outputDesc_[columnIndex - 1].dataType_;
+        if (dataType != Types.CLOB && dataType != Types.BLOB)
+           throw Messages.createSQLException(connection_.locale_, "restricted_data_type", null);
+        DataWrapper row = getCurrentRow();
+        wasNull_ = row.isNull(columnIndex);
+        if (wasNull_)
+           return null;
+        x = row.getObject(columnIndex);
+        wasNull_ = (x == null);
+        if (wasNull_)
+           data = null;
+        else {
+           if (x instanceof String) {
+               data = (String)x;
+           } else if (x instanceof byte[]) {
+               data = new String((byte[])x);
+           } 
+        }
+        return data;
+    }
+
 //--------------------------
 }
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXStatement.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXStatement.java
index 836a10f..3a5bd10 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXStatement.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/SQLMXStatement.java
@@ -47,13 +47,6 @@
 
 			if (batchCommands_ == null)
 				batchCommands_ = new ArrayList<String>();
-			// Scan the sql string for the special LOB EMPTY_CLOB() or
-			// EMPTY_BLOB()
-			// methods. This is required to replace the special method names in
-			// the sql string with a valid datalocator to insert for an empty
-			// row.
-			// SQL/MX does not know how to translate these special method names.
-			sql = scanSqlStr(sql);
 			batchCommands_.add(sql);
 		} finally {
 			if (JdbcDebugCfg.entryActive)
@@ -70,7 +63,7 @@
 			// and it is not yet seen by the application
 
 			synchronized (connection_) {
-				cancel(connection_.server_, connection_.getDialogueId_(), stmtId_);
+				cancel(connection_.server_, connection_.getDialogueId(), stmtId_);
 			}
 		} finally {
 			if (JdbcDebugCfg.entryActive)
@@ -143,8 +136,8 @@
 				beginTime=System.currentTimeMillis();
 				}
 				synchronized (connection_) {
-					executeDirect(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					executeDirect(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, getStmtLabel_(),
 							cursorName_, sql_.trim(), isSelect_, queryTimeout_,
 							resultSetHoldability_, resultSet_,this.stmtId_);
@@ -299,8 +292,8 @@
 				beginTime=System.currentTimeMillis();
 				}
 				synchronized (connection_) {
-					executeBatch(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					executeBatch(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, getStmtLabel_(),
 							cursorName_, batchCommands_.toArray(), isSelect_,
 							queryTimeout_, contBatchOnError,this.stmtId_);
@@ -393,8 +386,8 @@
 				beginTime=System.currentTimeMillis();
 				}
 				synchronized (connection_) {
-					executeDirect(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					executeDirect(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, getStmtLabel_(),
 							cursorName_, sql_.trim(), isSelect_, queryTimeout_,
 							resultSetHoldability_, resultSet_,this.stmtId_);
@@ -461,8 +454,8 @@
 				beginTime=System.currentTimeMillis();
 				}
 				synchronized (connection_) {
-					executeDirect(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					executeDirect(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, getStmtLabel_(),
 							cursorName_, sql_.trim(), isSelect_, queryTimeout_,
 							resultSetHoldability_, resultSet_,this.stmtId_);
@@ -690,7 +683,7 @@
 			if (JdbcDebugCfg.entryActive)
 				debug[methodId_getMoreResults_I]
 						.methodParameters("Pre-dialogueId_= "
-								+ connection_.getDialogueId_() + "  stmtId_= "
+								+ connection_.getDialogueId() + "  stmtId_= "
 								+ stmtId_ + "  resultSetMax_= " + resultSetMax_
 								+ "  resultSetIndex_= " + resultSetIndex_
 								+ "  isSPJResultSet_= " + isSPJResultSet_
@@ -699,8 +692,8 @@
 			// stmtLabel_ = ... append RSx to existing base RS stmtLabel_
 			SPJRSstmtLabel_ = SPJRSbaseStmtLabel_ + resultSetIndex_;
 
-			executeRS(connection_.server_, connection_.getDialogueId_(), connection_
-					.getTxid_(), connection_.autoCommit_,
+			executeRS(connection_.server_, connection_.getDialogueId(), connection_
+					.getTxid(), connection_.autoCommit_,
 					connection_.transactionMode_, getStmtLabel_(),
 					SPJRSstmtLabel_, isSelect_, stmtId_, resultSetIndex_,
 					resultSet_);
@@ -708,7 +701,7 @@
 			if (JdbcDebugCfg.entryActive)
 				debug[methodId_getMoreResults_I]
 						.methodParameters("Post-dialogueId_= "
-								+ connection_.getDialogueId_() + "  stmtId_= "
+								+ connection_.getDialogueId() + "  stmtId_= "
 								+ stmtId_ + "  resultSetMax_= " + resultSetMax_
 								+ "  resultSetIndex_= " + resultSetIndex_
 								+ "  isSPJResultSet_= " + isSPJResultSet_
@@ -775,7 +768,7 @@
 					if (JdbcDebugCfg.traceActive)
 						debug[methodId_getResultSet]
 								.methodParameters("Pre-dialogueId_= "
-										+ connection_.getDialogueId_()
+										+ connection_.getDialogueId()
 										+ "  stmtId_= " + stmtId_
 										+ "  resultSetMax_= " + resultSetMax_
 										+ "  resultSetIndex_= "
@@ -788,8 +781,8 @@
 					// to existing base SPJRS stmt label
 					SPJRSstmtLabel_ = SPJRSbaseStmtLabel_ + resultSetIndex_;
 
-					executeRS(connection_.server_, connection_.getDialogueId_(),
-							connection_.getTxid_(), connection_.autoCommit_,
+					executeRS(connection_.server_, connection_.getDialogueId(),
+							connection_.getTxid(), connection_.autoCommit_,
 							connection_.transactionMode_, getStmtLabel_(),
 							SPJRSstmtLabel_, isSelect_, stmtId_,
 							resultSetIndex_, resultSet_);
@@ -802,7 +795,7 @@
 					if (JdbcDebugCfg.traceActive)
 						debug[methodId_getResultSet]
 								.methodParameters("Post-dialogueId_= "
-										+ connection_.getDialogueId_()
+										+ connection_.getDialogueId()
 										+ "  stmtId_= " + stmtId_
 										+ "  resultSetMax_= " + resultSetMax_
 										+ "  resultSetIndex_= "
@@ -944,7 +937,7 @@
 
 				synchronized (connection_) {
 					// Pass the fetch size change to the driver
-					resetFetchSize(connection_.getDialogueId_(), stmtId_, fetchSize_);
+					resetFetchSize(connection_.getDialogueId(), stmtId_, fetchSize_);
 				}
 			}
 		} finally {
@@ -1062,80 +1055,13 @@
 		}
 	}
 
-	String scanSqlStr(String sql) throws SQLException {
-		if (JdbcDebugCfg.entryActive)
-			debug[methodId_scanSqlStr].methodEntry();
-		try {
-			String tempStr;
-			String tempSql;
-			int index = 0;
-			int oldIndex = 0;
-			StringBuffer newSql = null;
-			boolean clobFound = false;
-			boolean blobFound = false;
-			int len;
-
-			tempStr = sql.toUpperCase();
-			len = sql.length();
-			while (true) {
-				if ((index = tempStr.indexOf("EMPTY_CLOB()", oldIndex)) != -1) {
-					if (newSql == null)
-						newSql = new StringBuffer(len);
-					newSql.append(sql.substring(oldIndex, index));
-					newSql.append(Long.toString(connection_.getDataLocator(
-							connection_.clobTableName_, false)));
-					oldIndex = index + 12;
-					clobFound = true;
-				} else {
-					if (clobFound)
-						newSql.append(sql.substring(oldIndex));
-					break;
-				}
-			}
-			oldIndex = 0;
-			if (clobFound) {
-				tempSql = newSql.toString();
-				tempStr = tempSql.toUpperCase();
-			} else
-				tempSql = sql;
-
-			while (true) {
-				if ((index = tempStr.indexOf("EMPTY_BLOB()", oldIndex)) != -1) {
-					if (newSql == null) {
-						newSql = new StringBuffer(len);
-					} else {
-						if (!blobFound) // set the newSql to zero length for the
-							// first time
-							newSql.setLength(0);
-					}
-					newSql.append(tempSql.substring(oldIndex, index));
-					newSql.replace(index, index + 12, Long.toString(connection_
-							.getDataLocator(connection_.blobTableName_, true)));
-					blobFound = true;
-					oldIndex = index + 12;
-				} else {
-					if (blobFound)
-						newSql.append(tempSql.substring(oldIndex));
-					break;
-				}
-			}
-			if (clobFound || blobFound)
-				return newSql.toString();
-			else
-				return sql;
-		} finally {
-			if (JdbcDebugCfg.entryActive)
-				debug[methodId_scanSqlStr].methodExit();
-		}
-	}
-
 	void validateExecDirectInvocation(String sql) throws SQLException {
 		if (JdbcDebugCfg.entryActive)
 			debug[methodId_validateExecDirectInvocation_L].methodEntry();
 		try {
 			validateExecDirectInvocation();
 			isSelect_ = getStmtSqlType(sql);
-			sql_ = scanSqlStr(sql).trim();
+			sql_ = sql;
 			if(SQLMXConnection.getSqlStmtType(sql) == SQLMXConnection.TYPE_CONTROL){
 				connection_.setOfCQDs.add(sql);
 			}
@@ -1176,11 +1102,11 @@
 			synchronized (connection_) {
 				if (!connection_.isClosed_) {
 					if (stmtId_ != 0)
-						close(connection_.server_, connection_.getDialogueId_(),
+						close(connection_.server_, connection_.getDialogueId(),
 								stmtId_, true);
 					else
 						closeUsingLabel(connection_.server_,
-								connection_.getDialogueId_(), getStmtLabel_(), true);
+								connection_.getDialogueId(), getStmtLabel_(), true);
 				}
 			}// End sync
 		} finally {
@@ -1207,7 +1133,7 @@
 				// reduced
 				connection_.addElement(this);
 				// Check if the transaction is started by this Select statement
-				if (connection_.getTxid_() == 0 && txid != 0)
+				if (connection_.getTxid() == 0 && txid != 0)
 					resultSet_.txnStarted_ = true;
 				rowCount_ = -1;
 			} else {
@@ -1256,7 +1182,7 @@
 
 				// Check if the transaction is started by this Select statement
 				// if (connection_.txid_ == 0 && txid != 0) 
-				if (connection_.getTxid_() == txid) 
+				if (connection_.getTxid() == txid) 
 					resultSet_.txnStarted_ = true;
 				rowCount_ = -1;
 			} else {
@@ -1346,7 +1272,7 @@
 			if (JdbcDebugCfg.traceActive)
 				debug[methodId_firstResultSetExists]
 						.methodParameters("Pre-dialogueId_= "
-								+ connection_.getDialogueId_() + "  stmtId_= "
+								+ connection_.getDialogueId() + "  stmtId_= "
 								+ stmtId_ + "  resultSetMax_= " + resultSetMax_
 								+ "  resultSetIndex_= " + resultSetIndex_
 								+ "  isSPJResultSet_= " + isSPJResultSet_
@@ -1355,8 +1281,8 @@
 			// stmtLabel_ = ... append RSx to existing base RS stmtLabel_
 			SPJRSstmtLabel_ = SPJRSbaseStmtLabel_ + resultSetIndex_;
 
-			executeRS(connection_.server_, connection_.getDialogueId_(), connection_
-					.getTxid_(), connection_.autoCommit_,
+			executeRS(connection_.server_, connection_.getDialogueId(), connection_
+					.getTxid(), connection_.autoCommit_,
 					connection_.transactionMode_, getStmtLabel_(),
 					SPJRSstmtLabel_, isSelect_, stmtId_, resultSetIndex_,
 					resultSet_);
@@ -1364,7 +1290,7 @@
 			if (JdbcDebugCfg.traceActive)
 				debug[methodId_firstResultSetExists]
 						.methodParameters("Post-dialogueId_= "
-								+ connection_.getDialogueId_() + "  stmtId_= "
+								+ connection_.getDialogueId() + "  stmtId_= "
 								+ stmtId_ + "  resultSetMax_= " + resultSetMax_
 								+ "  resultSetIndex_= " + resultSetIndex_
 								+ "  isSPJResultSet_= " + isSPJResultSet_
@@ -1629,7 +1555,6 @@
 	private static int methodId_setMaxRows = 33;
 	private static int methodId_setQueryTimeout = 34;
 	private static int methodId_getStmtSqlType = 35;
-	private static int methodId_scanSqlStr = 36;
 	private static int methodId_validateExecDirectInvocation_L = 37;
 	private static int methodId_validateExecDirectInvocation_V = 38;
 	private static int methodId_internalClose = 39;
@@ -1713,7 +1638,6 @@
 					"setQueryTimeout");
 			debug[methodId_getStmtSqlType] = new JdbcDebug(className,
 					"getStmtSqlType");
-			debug[methodId_scanSqlStr] = new JdbcDebug(className, "scanSqlStr");
 			debug[methodId_validateExecDirectInvocation_L] = new JdbcDebug(
 					className, "validateExecDirectInvocation[L]");
 			debug[methodId_validateExecDirectInvocation_V] = new JdbcDebug(
diff --git a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/TConnection.java b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/TConnection.java
index 2ef22da..f933e74 100644
--- a/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/TConnection.java
+++ b/core/conn/jdbc_type2/src/main/java/org/apache/trafodion/jdbc/t2/TConnection.java
@@ -460,35 +460,6 @@
 		connection_.setTypeMap(map);
 	}
 
-	public PreparedStatement cpqPrepareStatement(String moduleName,
-			int moduleVersion, long moduleTimestamp, String stmtName,
-			boolean isSelect) throws SQLException {
-		PreparedStatement stmt;
-
-		if (out_ != null) {
-			out_.println(getTraceId() + "cpqPrepareStatement(\"" + moduleName
-					+ "\"," + moduleTimestamp + ", \"" + stmtName + "\", \""
-					+ isSelect + ")");
-		}
-
-		if (connection_ instanceof org.apache.trafodion.jdbc.t2.SQLMXConnection) {
-			stmt = ((org.apache.trafodion.jdbc.t2.SQLMXConnection) connection_)
-					.cpqPrepareStatement(moduleName, moduleVersion,
-							moduleTimestamp, stmtName, isSelect);
-		} else {
-			stmt = null;
-		}
-
-		if (out_ != null) {
-			out_.println(getTraceId() + "cpqPrepareStatement(\"" + moduleName
-					+ "\"," + moduleTimestamp + ", \"" + stmtName + "\", \""
-					+ isSelect + ") returns PreparedStatement ["
-					+ ((SQLMXStatement)((TPreparedStatement)stmt).stmt_).getStmtLabel_() + "]");
-		}
-
-		return new TPreparedStatement(stmt, out_);
-	}
-
 	// Constructors with access specifier as "default"
 	public TConnection(Connection connection, PrintWriter out)
 			throws SQLException {