JNIEXPORT jboolean JNICALL Java_org_trafodion_jdbc_t2_SQLMXResultSet_fetchN
  (JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId, jint txid, jint txnMode,
		jlong stmtId, 
		jint maxRowCnt, jint queryTimeout, jint holdability)
{
	FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXResultSet_fetchN",("server=%s, dialogueId=0x%08x, txid=0x%08x, txnMode=%ld, stmtId=0x%08x, maxRowCnt=%ld, queryTimeout=%ld, holdability=%ld",
		DebugJString(jenv,server),
		dialogueId,
		txid,
		txnMode,
		stmtId,
		maxRowCnt,
		queryTimeout,
		holdability));

	ExceptionStruct			exception_;
	SQLValueList_def		outputValueList;
	long					rowsAffected;
	BOOL					retCode = FALSE;
	ERROR_DESC_LIST_def		sqlWarning;
	jint					currentTxid = txid;
	jint					externalTxid = 0;
	const char				*nStmtLabel;
	
	SRVR_STMT_HDL	*pSrvrStmt;
	long			sqlcode;
	short			txn_status;

	if ((pSrvrStmt = getSrvrStmt(dialogueId, stmtId, &sqlcode)) == NULL)
	{
		throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", sqlcode);
		FUNCTION_RETURN_NUMERIC(false,("getSrvrStmt() returned NULL"));
	}

	if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, holdability)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		FUNCTION_RETURN_NUMERIC(false,("beginTxnControl() failed"));
	}

	odbc_SQLSvc_FetchN_sme_(NULL, NULL, &exception_,
			dialogueId, stmtId, maxRowCnt, FALSE, queryTimeout, &rowsAffected, &outputValueList,
			&sqlWarning);

	if ((txn_status = endTxnControl(jenv, currentTxid, 0, FALSE, 
		(exception_.exception_nr == odbc_SQLSvc_FetchN_SQLNoDataFound_exn_ ? CEE_SUCCESS : 
			exception_.exception_nr), TRUE, txnMode, externalTxid)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		FUNCTION_RETURN_NUMERIC(false,("endTxnControl() Failed"));
	}
	switch (exception_.exception_nr)
	{
	case CEE_SUCCESS:
		if (sqlWarning._length != 0)
			setSQLWarning(jenv, jobj, &sqlWarning);

		setFetchOutputs(jenv, jobj, pSrvrStmt, &outputValueList, rowsAffected, 
			rowsAffected < maxRowCnt ? TRUE : FALSE, TRUE, currentTxid);

		retCode = TRUE;
		break;
	case odbc_SQLSvc_FetchN_SQLNoDataFound_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		break;
	case odbc_SQLSvc_FetchN_SQLQueryCancelled_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		throwSQLException(jenv, QUERY_CANCELLED_ERROR, NULL, "HY008", 
			exception_.u.SQLQueryCancelled.sqlcode);
		break;
	case odbc_SQLSvc_FetchN_SQLError_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		throwSQLException(jenv, &exception_.u.SQLError);
		break;
	case odbc_SQLSvc_FetchN_ParamError_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
		break;
	case odbc_SQLSvc_FetchN_SQLInvalidHandle_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", exception_.u.SQLInvalidHandle.sqlcode);
		break;
	case odbc_SQLSvc_FetchN_SQLStillExecuting_exn_:
	case odbc_SQLSvc_FetchN_InvalidConnection_exn_:
	case odbc_SQLSvc_FetchN_TransactionError_exn_:
	default:
// TFDS
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
		throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
		break;
	}
	FUNCTION_RETURN_NUMERIC(retCode,(DebugBoolStr(retCode)));
}
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXCallableStatement_prepareCall
(JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId,
 jint txid, jboolean autoCommit, jint txnMode, jstring stmtLabel, jstring sql,
 jint queryTimeout, jint holdability, jint fetchSize)
{
	FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXCallableStatement_prepareCall",("... fetchSize=%ld",
		fetchSize));

	long					estimatedCost;
	long					inputParamOffset;
	ERROR_DESC_LIST_def			sqlWarning;
	SQLItemDescList_def			outputDesc;
	SQLItemDescList_def			inputDesc;
	jint						currentTxid = txid;
	jint						externalTxid = 0;
	jbyteArray					sqlByteArray;
	jboolean					isCopy;
	long						stmtId;
	jsize						len;
	SQLValue_def				sqlString;
	const char					*nSql = NULL;
	const char					*nStmtLabel = NULL;
	short						txn_status;

	ExceptionStruct exception_;
	CLEAR_EXCEPTION(exception_);

	sqlString.dataCharset = 0;
	sqlString.dataInd = 0;
	sqlString.dataType = SQLTYPECODE_VARCHAR;

	if (sql)
	{
		if ((sqlByteArray = (jbyteArray)jenv->CallObjectMethod(sql, gJNICache.getBytesMethodId))
			== NULL)
		{
			throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
			FUNCTION_RETURN_VOID(("CallObjectMethod() Failed"));
		}
		if ((nSql = (const char *)JNI_GetByteArrayElements(jenv,sqlByteArray, &isCopy)) == NULL)
		{
			throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
			FUNCTION_RETURN_VOID(("GetByteArrayElements() Failed"));
		}
		len = JNI_GetArrayLength(jenv,sqlByteArray);
		//Start Soln. No.: 10-091103-5969
		sqlString.dataValue._buffer = new unsigned char [len+1];
		memset(sqlString.dataValue._buffer,'\0',len+1);
		strncpy((char *)sqlString.dataValue._buffer,(const char *)nSql,len);
		//sqlString.dataValue._buffer = (unsigned char *)nSql;
		//End Soln. No.: 10-091103-5969
		sqlString.dataValue._length = len;
	}
	else
	{
		throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
		FUNCTION_RETURN_VOID(("SQL string is Null"));
	}

	if (stmtLabel)
		nStmtLabel = JNI_GetStringUTFChars(jenv,stmtLabel, NULL);
	else
	{
		throwSQLException(jenv, INVALID_STMT_LABEL_ERROR, NULL, "HY000");
		FUNCTION_RETURN_VOID(("stmtLabel is Null"));
	}

	if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, -1)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
	}

	odbc_SQLSvc_Prepare_sme_(NULL, NULL,
		&exception_,
		dialogueId,
		nStmtLabel,
		"",					// StmtExplainName
		EXTERNAL_STMT,
		&sqlString,
		holdability,
		TYPE_CALL,
		0,
		fetchSize,
		queryTimeout,
		&estimatedCost,
		&inputDesc,
		&outputDesc,
		&sqlWarning,
		&stmtId,
		&inputParamOffset,
		NULL, // MFC
		false);

	if (sql)
	{
		JNI_ReleaseByteArrayElements(jenv,sqlByteArray, (jbyte *)nSql, JNI_ABORT);
	}

	if (stmtLabel)
		JNI_ReleaseStringUTFChars(jenv,stmtLabel, nStmtLabel);

	if ((txn_status = endTxnControl(jenv, currentTxid, txid, autoCommit, CEE_SUCCESS, FALSE, txnMode, externalTxid)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		FUNCTION_RETURN_VOID(("endTxnControl() Failed"));
	}

	switch (exception_.exception_nr)
	{
	case CEE_SUCCESS:
		outputDesc._length = 0;
		outputDesc._buffer = 0;
		setPrepareOutputs(jenv, jobj, &inputDesc, &outputDesc, currentTxid, stmtId, inputParamOffset);
		if (sqlWarning._length > 0)
			setSQLWarning(jenv, jobj, &sqlWarning);
		break;
	case odbc_SQLSvc_Prepare_SQLQueryCancelled_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, QUERY_CANCELLED_ERROR, NULL, "HY008",
			exception_.u.SQLQueryCancelled.sqlcode);
		break;
	case odbc_SQLSvc_Prepare_SQLError_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, &exception_.u.SQLError);
		break;
	case odbc_SQLSvc_Prepare_ParamError_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
		break;
	case odbc_SQLSvc_Prepare_SQLInvalidHandle_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", exception_.u.SQLInvalidHandle.sqlcode);
		break;
	case odbc_SQLSvc_Prepare_InvalidConnection_exn_:
	case odbc_SQLSvc_Prepare_SQLStillExecuting_exn_:
	case odbc_SQLSvc_Prepare_TransactionError_exn_:
	default:
		// TFDS - These exceptions should not happen
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
		break;
	}
	FUNCTION_RETURN_VOID((NULL));
}
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXResultSet_close
  (JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId, jint txid, jboolean autoCommit, jint txnMode,
	jlong stmtId, jboolean dropStmt)
{
	FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXResultSet_close",("server=%s, dialogueId=0x%08x, txid=0x%08x, autoCommit=%s, txnMode=%ld, stmtId=0x%08x, dropStmt=%s",
		DebugJString(jenv,server),
		dialogueId,
		txid,
		DebugBoolStr(autoCommit),
		txnMode,
        	stmtId,
		DebugBoolStr(dropStmt)));

	jint						currentTxid = txid;
	jint						externalTxid = 0;
	jboolean					selectStmt = FALSE;
	ExceptionStruct				exception_;
	long						rowsAffected;
	ERROR_DESC_LIST_def			sqlWarning;
	short						txn_status;
	
	ERROR_DESC_def				*error_desc_def;
	// Don't bother resuming the transaction, if it is already zero. Try and close the cursor
	if (currentTxid != 0)
	{
		if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, CLOSE_CURSORS_AT_COMMIT)) != 0 )
		{
			jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
			throwTransactionException(jenv, txn_status);
			FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
		}
	}
	
	odbc_SQLSvc_Close_sme_(NULL, NULL, &exception_,
					dialogueId,
					stmtId,
					(dropStmt ? SQL_DROP : SQL_CLOSE),
					&rowsAffected,
					&sqlWarning);
	
	if (currentTxid != 0)
	{
		if ((txn_status = endTxnControl(jenv, currentTxid, 0, autoCommit, 0, selectStmt, txnMode, externalTxid)) != 0)
		{
			jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
			throwTransactionException(jenv, txn_status);
			FUNCTION_RETURN_VOID(("endTxnControl() failed"));
		}
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidRSMethodId, currentTxid);
	}	
	
	switch (exception_.exception_nr)
	{
	case CEE_SUCCESS:
		// Not updating rowsAffected, since it is not useful in JDBC
		if (sqlWarning._length != 0)
			setSQLWarning(jenv, jobj, &sqlWarning);
		selectStmt = FALSE;
		break;
	case odbc_SQLSvc_Close_SQLError_exn_:
		error_desc_def =((ERROR_DESC_LIST_def *)(&exception_.u.SQLError.errorList))->_buffer;
		if (error_desc_def->sqlcode == -8811)		// Close a non-existant cursor and hence don't end 
													// the transaction by treating it like Select stmt
			selectStmt = TRUE;	
		// sql Error in case of close could be treated as SQLWarning
		setSQLWarning(jenv, jobj, &exception_.u.SQLError.errorList);
		break;
	case odbc_SQLSvc_Close_ParamError_exn_:
		throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
		break;
	case odbc_SQLSvc_Close_InvalidConnection_exn_:
	case odbc_SQLSvc_Close_TransactionError_exn_:
	default:
	// TFDS - This exceptions should not happen
		throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
		break;
	}
	FUNCTION_RETURN_VOID((NULL));
}
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXCallableStatement_cpqPrepareCall
(JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId,
 jint txid, jboolean autoCommit, jint txnMode,
 jstring moduleName, jint moduleVersion, jlong moduleTimestamp, jstring stmtName,
 jint queryTimeout, jint holdability, jint fetchSize)
{
	FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXCallableStatement_cpqPrepareCall",("..."));

	long							estimatedCost;
	long							inputParamOffset;
	ERROR_DESC_LIST_def				sqlWarning;
	SQLItemDescList_def				outputDesc;
	SQLItemDescList_def				inputDesc;
	jint							currentTxid = txid;
	jint							externalTxid = 0;
	long							stmtId;
	const char						*nModuleName = NULL;
	const char						*nStmtName = NULL;
	short							txn_status;

	ExceptionStruct	exception_;
	CLEAR_EXCEPTION(exception_);

	if (moduleName)
		nModuleName = JNI_GetStringUTFChars(jenv,moduleName, NULL);
	else
	{
		throwSQLException(jenv, INVALID_MODULE_NAME_ERROR, NULL, "HY000");
		FUNCTION_RETURN_VOID(("moduleName is Null"));
	}

	if (stmtName)
		nStmtName = JNI_GetStringUTFChars(jenv,stmtName, NULL);
	else
	{
		throwSQLException(jenv, INVALID_STMT_LABEL_ERROR, NULL, "HY000");
		FUNCTION_RETURN_VOID(("stmtName is Null"));
	}

	if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, -1)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
	}

	odbc_SQLSvc_PrepareFromModule_sme_(NULL, NULL,
		&exception_,
		dialogueId,
		(char *)nModuleName,
		moduleVersion,
		moduleTimestamp,
		(char *)nStmtName,
		TYPE_CALL,
		fetchSize,
		0,
		0,
		&estimatedCost,
		&inputDesc,
		&outputDesc,
		&sqlWarning,
		&stmtId,
		&inputParamOffset);

	if (moduleName)
		JNI_ReleaseStringUTFChars(jenv,moduleName, nModuleName);

	if (stmtName)
		JNI_ReleaseStringUTFChars(jenv,stmtName, nStmtName);

	// Prepare, don't abort transaction even if there is an error, hence CEE_SUCCESS
	if ((txn_status = endTxnControl(jenv, currentTxid, txid,
		autoCommit, CEE_SUCCESS, FALSE, txnMode, externalTxid)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		FUNCTION_RETURN_VOID(("endTxnControl() Failed"));
	}

	switch (exception_.exception_nr)
	{
	case CEE_SUCCESS:
		outputDesc._length = 0;
		outputDesc._buffer = 0;
		setPrepareOutputs(jenv, jobj, &inputDesc, &outputDesc, currentTxid, stmtId, inputParamOffset);
		if (sqlWarning._length > 0)
			setSQLWarning(jenv, jobj, &sqlWarning);
		break;
	case odbc_SQLSvc_PrepareFromModule_SQLQueryCancelled_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, QUERY_CANCELLED_ERROR, NULL, "HY008",
			exception_.u.SQLQueryCancelled.sqlcode);
		break;
	case odbc_SQLSvc_PrepareFromModule_SQLError_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, &exception_.u.SQLError);
		break;
	case odbc_SQLSvc_PrepareFromModule_ParamError_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, MODULE_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
		break;
	case odbc_SQLSvc_PrepareFromModule_SQLStillExecuting_exn_:
	case odbc_SQLSvc_PrepareFromModule_InvalidConnection_exn_:
	case odbc_SQLSvc_PrepareFromModule_TransactionError_exn_:
	default:
		// TFDS - These exceptions should not happen
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
		break;
	}
	FUNCTION_RETURN_VOID((NULL));
}
//venu changed from int to long for 64 bit
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXCallableStatement_executeCall
(JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId,
 jint txid, jboolean autoCommit, jint txnMode, jlong stmtId,
 jint paramCount, jobject paramValues, jint queryTimeout, jstring iso88591Encoding)
{
	FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXCallableStatement_executeCall",("..."));

	SQLValueList_def				outputSqlValueList;
	ERROR_DESC_LIST_def				sqlWarning;
	jint							currentTxid = txid;
	jint							externalTxid = 0;
	short							returnResultSet;
	long							sqlcode;
	short							txn_status;

	SQLValueList_def				inputSqlValueList;
	CLEAR_LIST(inputSqlValueList);
	ExceptionStruct	exception_;
	CLEAR_EXCEPTION(exception_);

	SRVR_STMT_HDL	*pSrvrStmt;

	if ((pSrvrStmt = getSrvrStmt(dialogueId, stmtId, &sqlcode)) == NULL)
	{
		throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", sqlcode);
		FUNCTION_RETURN_VOID(("getSrvrStmt() Failed"));
	}
	CLI_DEBUG_SHOW_SERVER_STATEMENT(pSrvrStmt);
	inputSqlValueList._buffer = NULL;
	inputSqlValueList._length = 0;

	if (fillInSQLValues(jenv, jobj, pSrvrStmt,
		0, 1, paramCount, paramValues, iso88591Encoding))
		FUNCTION_RETURN_VOID(("fillInSQLValues() Failed"));

	if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, -1)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
	}

	odbc_SQLSvc_ExecuteCall_sme_(NULL, NULL,
		&exception_,
		dialogueId,
		stmtId,
		&inputSqlValueList,
		FALSE,
		queryTimeout,
		&outputSqlValueList,
		&returnResultSet,
		&sqlWarning);

	if ((txn_status = endTxnControl(jenv, currentTxid, txid, autoCommit, exception_.exception_nr,
		pSrvrStmt->isSPJRS, txnMode, externalTxid)) != 0)
	{
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwTransactionException(jenv, txn_status);
		DEBUG_OUT(DEBUG_LEVEL_ENTRY,("endTxnControl() Failed"));
	}

	switch (exception_.exception_nr)
	{
	case CEE_SUCCESS:

		setExecuteCallOutputs(jenv, jobj, pSrvrStmt, returnResultSet, currentTxid);
		DEBUG_OUT(DEBUG_LEVEL_STMT,("RSMax: %d  RSIndex: %d  isSPJResultSet: %d",
			pSrvrStmt->RSMax, pSrvrStmt->RSIndex, pSrvrStmt->isSPJRS));

		if (sqlWarning._length > 0)
			setSQLWarning(jenv, jobj, &sqlWarning);
		break;
	case odbc_SQLSvc_ExecuteCall_SQLQueryCancelled_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, QUERY_CANCELLED_ERROR, NULL, "HY008",
			exception_.u.SQLQueryCancelled.sqlcode);
		break;
	case odbc_SQLSvc_ExecuteCall_SQLError_exn_:
	case odbc_SQLSvc_ExecuteCall_SQLRetryCompile_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, &exception_.u.SQLError);
		break;
	case odbc_SQLSvc_ExecuteCall_ParamError_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
		break;
	case odbc_SQLSvc_ExecuteCall_SQLInvalidHandle_exn_:
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", exception_.u.SQLInvalidHandle.sqlcode);
		break;
	case odbc_SQLSvc_ExecuteCall_SQLStillExecuting_exn_:
	case odbc_SQLSvc_ExecuteCall_InvalidConnection_exn_:
	case odbc_SQLSvc_ExecuteCall_TransactionError_exn_:
	case odbc_SQLSvc_ExecuteCall_SQLNeedData_exn_:
	default:
		// TFDS - These exceptions should not happen
		jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
		throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
		break;
	}
	FUNCTION_RETURN_VOID((NULL));
}
Ejemplo n.º 6
0
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXStatement_executeDirect
(JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId, jint txid, jboolean autoCommit, jint txnMode,
 jstring stmtLabel, jstring cursorName, jstring sql, jboolean isSelect, jint queryTimeout,
 jint holdability, jobject resultSet, jlong currentStmtId)
{
    FUNCTION_ENTRY_LEVEL(DEBUG_LEVEL_STMT,"Java_org_trafodion_jdbc_t2_SQLMXStatement_executeDirect",
                         ("... dialogueId=0x%08x, txid=%ld, autoCommit=%s, stmtLabel=%s, cursorName=%s, sql=%s, txnMode=%ld, isSelect=%s, holdability=%ld, resultSet=0x%08x",
                          dialogueId,
                          txid,
                          DebugBoolStr(autoCommit),
                          DebugJString(jenv,stmtLabel),
                          DebugJString(jenv,cursorName),
                          DebugJString(jenv,sql),
                          txnMode,
                          DebugBoolStr(isSelect),
                          holdability,
                          resultSet));

    ExceptionStruct				exception_;
    long					estimatedCost;
    long					rowsAffected;
    ERROR_DESC_LIST_def			sqlWarning;
    SQLItemDescList_def			outputDesc;
    jint						currentTxid = txid;
    jint						externalTxid = 0;
    long						stmtId;

    const char		*nSql;
    const char		*nStmtLabel;
    const char		*nCursorName;
    jbyteArray		sqlByteArray;
    jboolean		isCopy;
    jsize			len;
    SQLValue_def	sqlString;
    short			txn_status;

    sqlString.dataCharset = 0;
    sqlString.dataInd = 0;
    sqlString.dataType = SQLTYPECODE_VARCHAR;

    if (sql)
    {
        if ((sqlByteArray = (jbyteArray)jenv->CallObjectMethod(sql, gJNICache.getBytesMethodId))
                == NULL)
        {
            throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
            FUNCTION_RETURN_VOID(("getBytesMethod returned NULL"));
        }
        if ((nSql = (const char *)JNI_GetByteArrayElements(jenv,sqlByteArray, &isCopy)) == NULL)
        {
            throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
            FUNCTION_RETURN_VOID(("GetByteArrayElements returned NULL"));
        }
        len = JNI_GetArrayLength(jenv,sqlByteArray);
        sqlString.dataValue._buffer = (unsigned char *)nSql;
        sqlString.dataValue._length = len;
        DEBUG_OUT(DEBUG_LEVEL_CLI,("sqlString = '%s', length =%ld", nSql, len));
        MEMORY_DUMP(DEBUG_LEVEL_CLI, nSql, len);
    }
    else
    {
        throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
        FUNCTION_RETURN_VOID(("sql is NULL"));
    }

    if (stmtLabel)
        nStmtLabel = JNI_GetStringUTFChars(jenv,stmtLabel, NULL);
    else
    {
        throwSQLException(jenv, INVALID_STMT_LABEL_ERROR, NULL, "HY000");
        FUNCTION_RETURN_VOID(("stmtLabel is NULL"));
    }

    if (cursorName)
        nCursorName = JNI_GetStringUTFChars(jenv,cursorName, NULL);
    else
        nCursorName = NULL;

    if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, -1) != 0))
    {
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwTransactionException(jenv, txn_status);
        FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
    }

    exception_.u.SQLError.errorList._buffer = NULL;
    odbc_SQLSvc_ExecDirect_sme_(NULL, NULL,
                                &exception_,
                                dialogueId,
                                nStmtLabel,
                                (char *)nCursorName,
                                "",					// StmtExplainName
                                EXTERNAL_STMT,
                                (isSelect ? TYPE_SELECT : TYPE_UNKNOWN),
                                &sqlString,
                                holdability,
                                queryTimeout,
                                (long) resultSet,
                                &estimatedCost,
                                &outputDesc,
                                &rowsAffected,
                                &sqlWarning,
                                &stmtId,
                                currentStmtId);

    if (sql)
        JNI_ReleaseByteArrayElements(jenv,sqlByteArray, (jbyte *)nSql, JNI_ABORT);
    if (stmtLabel)
        JNI_ReleaseStringUTFChars(jenv,stmtLabel, nStmtLabel);
    if (cursorName)
        JNI_ReleaseStringUTFChars(jenv,cursorName, nCursorName);

    if ((txn_status = endTxnControl(jenv, currentTxid, txid, autoCommit,
                                    exception_.exception_nr, isSelect, txnMode, externalTxid)) != 0)
    {
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwTransactionException(jenv, txn_status);
        FUNCTION_RETURN_VOID(("endTxnControl() Failed"));
    }

    switch (exception_.exception_nr)
    {
    case CEE_SUCCESS:
        if (sqlWarning._length != 0)
            setSQLWarning(jenv, jobj, &sqlWarning);
        setExecuteDirectOutputs(jenv, jobj, &outputDesc, rowsAffected, currentTxid, stmtId);
        break;
    case odbc_SQLSvc_ExecDirect_ParamError_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
        break;
    case odbc_SQLSvc_ExecDirect_SQLError_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, &exception_.u.SQLError);
        break;
    case odbc_SQLSvc_ExecDirect_SQLQueryCancelled_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, QUERY_CANCELLED_ERROR, NULL, "HY008",
                          exception_.u.SQLQueryCancelled.sqlcode);
        break;
    case odbc_SQLSvc_ExecDirect_SQLInvalidHandle_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", exception_.u.SQLInvalidHandle.sqlcode);
        break;
    case odbc_SQLSvc_ExecDirect_SQLStillExecuting_exn_:
    case odbc_SQLSvc_ExecDirect_InvalidConnection_exn_:
    case odbc_SQLSvc_ExecDirect_TransactionError_exn_:
    default:
// TFDS - These error should not happen
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
        break;
    }
    FUNCTION_RETURN_VOID((NULL));
}
Ejemplo n.º 7
0
/* RFE: Batch update improvements
 * executeBatch() now contains an additional argument: contBatchOnError
 */
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXStatement_executeBatch
(JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId, jint txid, jboolean autoCommit, jint txnMode,
 jstring stmtLabel, jstring cursorName, jobjectArray sqlCommands, jboolean isSelect, jint queryTimeout, jboolean contBatchOnError, jlong currentStmtId)
{
    FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXStatement_executeBatch",
                   ("... dialogueId=0x%08x, txid=%ld, autoCommit=%s, stmtLabel=%s, cursorName=%s,txnMode=%ld, isSelect=%s,contBatchOnError=%s ...",
                    dialogueId,
                    txid,
                    DebugBoolStr(autoCommit),
                    DebugJString(jenv,stmtLabel),
                    DebugJString(jenv,cursorName),
                    txnMode,
                    DebugBoolStr(isSelect),
                    DebugBoolStr(contBatchOnError)));

    ExceptionStruct				exception_;
    long						estimatedCost;
    long						rowsAffected;
    ERROR_DESC_LIST_def			sqlWarning;
    SQLItemDescList_def			outputDesc;
    jint						currentTxid = txid;
    jint						externalTxid = 0;
    jsize						noOfCommands;
    jstring						sql;
    jint						i;

    const char		*nSql;
    const char		*nStmtLabel;
    const char		*nCursorName = NULL;
    jbyteArray		sqlByteArray;
    jboolean		isCopy;
    long			stmtId;
    jsize			len;
    SQLValue_def	sqlString;
    short			txn_status;
    // RFE: Batch update improvements
    jthrowable		queuedException = NULL;
    jthrowable		exceptionHead = NULL;
    bool			isSuspended = false;

    exception_.exception_nr = CEE_SUCCESS;

    if (stmtLabel)
        nStmtLabel = JNI_GetStringUTFChars(jenv,stmtLabel, NULL);
    else
    {
        throwSQLException(jenv, INVALID_STMT_LABEL_ERROR, NULL, "HY000");
        FUNCTION_RETURN_VOID(("stmtLabel is NULL"));
    }

    if (cursorName) nCursorName = JNI_GetStringUTFChars(jenv,cursorName, NULL);

    if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, -1) != 0))
    {
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwTransactionException(jenv, txn_status);
        FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
    }

    sqlString.dataCharset = 0;
    sqlString.dataInd = 0;
    sqlString.dataType = SQLTYPECODE_VARCHAR;

    noOfCommands = JNI_GetArrayLength(jenv,sqlCommands);

    for (i = 0; i < noOfCommands ; i++)
    {
        /* RFE: Batch update improvements
         * Resume the transaction if it was earlier suspended, by checking the
         * variable isSuspended. This is reset to false after the transaction is resumed.
         */
        if(isSuspended)
        {
            if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, -1) != 0))
            {
                jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
                throwTransactionException(jenv, txn_status);
                FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
            }
            isSuspended = false;
        }
        sql = (jstring) JNI_GetObjectArrayElement(jenv,sqlCommands, i);
        if (sql)
        {
            if ((sqlByteArray = (jbyteArray)jenv->CallObjectMethod(sql, gJNICache.getBytesMethodId))
                    == NULL)
            {
                throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
                FUNCTION_RETURN_VOID(("getBytesMethod() returned NULL"));
            }
            if ((nSql = (const char *)JNI_GetByteArrayElements(jenv,sqlByteArray, &isCopy)) == NULL)
            {
                throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
                FUNCTION_RETURN_VOID(("GetByteArrayElements() returned NULL"));
            }
            len = JNI_GetArrayLength(jenv,sqlByteArray);
            sqlString.dataValue._buffer = (unsigned char *)nSql;
            sqlString.dataValue._length = len;
        }
        else
        {
            throwSQLException(jenv, INVALID_SQL_STRING_ERROR, NULL, "HY090");
            FUNCTION_RETURN_VOID(("sql is NULL"));
        }

        odbc_SQLSvc_ExecDirect_sme_(NULL, NULL,
                                    &exception_,
                                    dialogueId,
                                    nStmtLabel,
                                    (char *)nCursorName,
                                    "",					// StmtExplainName
                                    EXTERNAL_STMT,
                                    (isSelect ? TYPE_SELECT : TYPE_UNKNOWN),
                                    &sqlString,
                                    CLOSE_CURSORS_AT_COMMIT,
                                    queryTimeout,
                                    NULL,
                                    &estimatedCost,
                                    &outputDesc,
                                    &rowsAffected,
                                    &sqlWarning,
                                    &stmtId
                                    ,currentStmtId);

        if (sql)
            JNI_ReleaseByteArrayElements(jenv,sqlByteArray, (jbyte *)nSql, JNI_ABORT);

        /* RFE: Batch update improvements
         * Perform pre-function exit processing only if contBatchOnError is not set to true
         */
        if (exception_.exception_nr != CEE_SUCCESS)
        {
            //RFE: Batch update improvements
            if(!contBatchOnError)
            {
                if (stmtLabel)
                    JNI_ReleaseStringUTFChars(jenv,stmtLabel, nStmtLabel);
                if (cursorName)
                    JNI_ReleaseStringUTFChars(jenv,cursorName, nCursorName);
            }

            // Commit the transaction so all good statements are processed.
            txn_status = endTxnControl(jenv, currentTxid, txid, autoCommit,
                                       CEE_SUCCESS, isSelect, txnMode, externalTxid);
            jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
            if (txn_status != 0)
            {
                throwTransactionException(jenv, txn_status);
                DEBUG_OUT(DEBUG_LEVEL_ENTRY|DEBUG_LEVEL_TXN,("endTxnControl() Failed after ExecDirect failure"));
            }
            //RFE: Batch update improvements
            if(contBatchOnError)
                isSuspended = true;

        }

        switch (exception_.exception_nr)
        {
        case CEE_SUCCESS:
            if (sqlWarning._length != 0)
                setSQLWarning(jenv, jobj, &sqlWarning);
            jenv->CallVoidMethod(jobj, gJNICache.execDirectBatchOutputsMethodId, i, rowsAffected,
                                 currentTxid);
            break;
        case odbc_SQLSvc_ExecDirect_ParamError_exn_:
            jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
            throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
            break;
        case odbc_SQLSvc_ExecDirect_SQLError_exn_:
            jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
            throwSQLException(jenv, &exception_.u.SQLError);
            break;
        case odbc_SQLSvc_ExecDirect_SQLQueryCancelled_exn_:
            jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
            throwSQLException(jenv, QUERY_CANCELLED_ERROR, NULL, "HY008",
                              exception_.u.SQLQueryCancelled.sqlcode);
            break;
        case odbc_SQLSvc_ExecDirect_SQLInvalidHandle_exn_:
            jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
            throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", exception_.u.SQLInvalidHandle.sqlcode);
            break;
        case odbc_SQLSvc_ExecDirect_SQLStillExecuting_exn_:
        case odbc_SQLSvc_ExecDirect_InvalidConnection_exn_:
        case odbc_SQLSvc_ExecDirect_TransactionError_exn_:
        default:
            // TFDS - These error should not happen
            jenv->CallVoidMethod(jobj, gJNICache.setCurrentStmtIdMethodId, stmtId);
            throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
            break;
        }
        /* RFE: Batch update improvements
         * Return to caller on error and if contBatchOnError is not true.
         */
        if (exception_.exception_nr != CEE_SUCCESS && !contBatchOnError)
            FUNCTION_RETURN_VOID(("exception_.exception_nr(%ld) is not CEE_SUCCESS",exception_.exception_nr));

        /* RFE: Batch update improvements
         * Queue up the exceptions.
         */
        if(jenv->ExceptionOccurred())
        {
            queuedException = jenv->ExceptionOccurred();
            if(exceptionHead)
                jenv->CallVoidMethod(exceptionHead, gJNICache.setNextExceptionMethodId,
                                     queuedException);
            else
                exceptionHead = queuedException;
        }

    }//end of for

    if (stmtLabel)
        JNI_ReleaseStringUTFChars(jenv,stmtLabel, nStmtLabel);

    if (cursorName)
        JNI_ReleaseStringUTFChars(jenv,cursorName, nCursorName);

    /* RFE: Batch update improvements
     * If contBatchOnError is true, CEE_SUCCESS is always passed instead of
     * exception_.exception_nr, so that endTxnControl suspends the transaction.
     */
    txn_status = endTxnControl(jenv, currentTxid, txid, autoCommit,
                               (contBatchOnError ? CEE_SUCCESS:exception_.exception_nr), isSelect, txnMode, externalTxid);
    jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
    if (txn_status != 0)
    {
        throwTransactionException(jenv, txn_status);
        FUNCTION_RETURN_VOID(("endTxnControl() failed"));
    }
    /* RFE: Batch update improvements
     * Throw the queued exception if any */
    if(exceptionHead)
        jenv->Throw(exceptionHead);
    FUNCTION_RETURN_VOID((NULL));
}
Ejemplo n.º 8
0
//venu changed dialogueId and stmtId from int to long for 64 bit
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXStatement_executeRS
(JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId, jint txid, jboolean autoCommit, jint txnMode,
 jstring stmtLabel, jstring RSstmtLabel,  jboolean isSelect, jlong stmtId, jint ResultSetIndex, jobject resultSet)
{
    FUNCTION_ENTRY_LEVEL(DEBUG_LEVEL_STMT, "Java_org_trafodion_jdbc_t2_SQLMXStatement_executeRS",
                         ("...dialogueId=0x%08x, txid=0x%08x, stmtLabel=%s, RSstmtLabel=%s, isSelect=%s, stmtId=0x%08x, ResultSetIndex=%ld, resultSet=0x%08x",
                          dialogueId,
                          txid,
                          DebugJString(jenv,stmtLabel),
                          DebugJString(jenv,RSstmtLabel),
                          DebugBoolStr(isSelect),
                          stmtId,
                          ResultSetIndex,
                          resultSet));

    ExceptionStruct				exception_;
    ERROR_DESC_LIST_def			sqlWarning;
    SQLItemDescList_def			outputDesc;
    jint						currentTxid = txid;
    jint						externalTxid = 0;
    long						RSstmtId;
    const char					*nStmtLabel;
    const char					*nRSStmtLabel;
    jboolean					isCopy;
    short						txn_status;

    if (stmtLabel)
        nStmtLabel = JNI_GetStringUTFChars(jenv,stmtLabel, NULL);
    else
    {
        throwSQLException(jenv, INVALID_STMT_LABEL_ERROR, NULL, "HY000");
        FUNCTION_RETURN_VOID(("stmtLabel is NULL"));
    }
    if (RSstmtLabel)
        nRSStmtLabel = JNI_GetStringUTFChars(jenv,RSstmtLabel, NULL);
    else
    {
        throwSQLException(jenv, INVALID_STMT_LABEL_ERROR, NULL, "HY000");
        FUNCTION_RETURN_VOID(("RSstmtLabel is NULL"));
    }

    if ((txn_status = beginTxnControl(jenv, currentTxid, externalTxid, txnMode, -1) != 0))
    {
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwTransactionException(jenv, txn_status);
        FUNCTION_RETURN_VOID(("beginTxnControl() failed"));
    }

    jdbc_SQLSvc_ExecSPJRS_sme_(NULL, NULL,
                               &exception_,
                               dialogueId,
                               nStmtLabel,
                               nRSStmtLabel,
                               EXTERNAL_STMT,
                               (isSelect ? TYPE_SELECT : TYPE_UNKNOWN),
                               (long) resultSet,
                               ResultSetIndex,
                               &outputDesc,
                               &sqlWarning,
                               &RSstmtId,
                               stmtId);

    if (stmtLabel)
        JNI_ReleaseStringUTFChars(jenv, stmtLabel, nStmtLabel);

    if (RSstmtLabel)
        JNI_ReleaseStringUTFChars(jenv, RSstmtLabel, nRSStmtLabel);

    if ((txn_status = endTxnControl(jenv, currentTxid, txid, autoCommit,
                                    exception_.exception_nr, isSelect, txnMode, externalTxid)) != 0)
    {
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwTransactionException(jenv, txn_status);
        FUNCTION_RETURN_VOID(("endTxnControl() Failed"));
    }

    switch (exception_.exception_nr)
    {
    case CEE_SUCCESS:
        if (sqlWarning._length != 0)
            setSQLWarning(jenv, jobj, &sqlWarning);
        setExecuteRSOutputs(jenv, jobj, &outputDesc, currentTxid, RSstmtId, ResultSetIndex);
        break;
    case jdbc_SQLSvc_ExecSPJRS_ParamError_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000");
        break;
    case jdbc_SQLSvc_ExecSPJRS_SQLError_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, &exception_.u.SQLError);
        break;
    case jdbc_SQLSvc_ExecSPJRS_SQLQueryCancelled_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, QUERY_CANCELLED_ERROR, NULL, "HY008", exception_.u.SQLQueryCancelled.sqlcode);
        break;
    case jdbc_SQLSvc_ExecSPJRS_SQLInvalidHandle_exn_:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", exception_.u.SQLInvalidHandle.sqlcode);
        break;
    case jdbc_SQLSvc_ExecSPJRS_SQLStillExecuting_exn_:
    case jdbc_SQLSvc_ExecSPJRS_InvalidConnection_exn_:
    case jdbc_SQLSvc_ExecSPJRS_TransactionError_exn_:
    default:
        jenv->CallVoidMethod(jobj, gJNICache.setCurrentTxidStmtMethodId, currentTxid);
        throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr);
        break;
    }
    FUNCTION_RETURN_VOID((NULL));
}