/* * Class: org_trafodion_jdbc_t2_T2Driver * Method: checkLibraryVersion * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_T2Driver_checkLibraryVersion(JNIEnv *jenv, jclass jcls, jstring javaVproc) { #ifdef NSK_PLATFORM // Linux port - ToDo txn related int cliret = client_initialization();//by venu for TSLX if (cliret != 1)//client init return 1 on success { DEBUG_OUT(DEBUG_LEVEL_TXN,("TSLX initialization failed %d", cliret)); } DEBUG_OUT(DEBUG_LEVEL_TXN,("TSLX Initialization done")); #endif //Added for R3.0 Transaction issue sol. 10-100430-9906 FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_T2Driver_checkLibraryVersion",("javaVproc=%s", DebugJString(jenv,javaVproc))); // Set the TMLIB cleanup setTM_enable_cleanup(); #ifdef NSK_PLATFORM // Linux port short status = tmfInit(); DEBUG_OUT(DEBUG_LEVEL_TXN,("tmfInit() returned %d", status)); if (status != 0) { throwTransactionException(jenv, status); FUNCTION_RETURN_VOID(("status(%d) is non-zero",status)); } #endif //End if (javaVproc && !driverVersionChecked) { const char *java_vproc_str = JNI_GetStringUTFChars(jenv,javaVproc, NULL); if (java_vproc_str) { if (strcmp(java_vproc_str,driverVproc)!=0) { printf("JDBC Library Version Error - Jar: %s Jni: %s\n", java_vproc_str,driverVproc); abort(); } JNI_ReleaseStringUTFChars(jenv,javaVproc, java_vproc_str); driverVersionChecked = true; } } FUNCTION_RETURN_VOID((NULL)); }
//venu changed dialogueId and stmtId from int to long for 64 bit JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXResultSet_getResultSetInfo (JNIEnv *jenv, jobject jobj, jlong dialogueId, jlong stmtId, jobject RSInfo) { FUNCTION_ENTRY_LEVEL(DEBUG_LEVEL_STMT,"Java_org_trafodion_jdbc_t2_SQLMXResultSet_getResultSetInfo", ("dialogueId=0x%08x, stmtId=0x%08x, RSInfo=0x%08x", dialogueId, stmtId, RSInfo)); SQLCTX_HANDLE ctxHandle; SRVR_STMT_HDL *pSrvrStmt; long sqlcode; // Get the Statement ID if ((pSrvrStmt = getSrvrStmt(dialogueId, stmtId, &sqlcode)) == NULL) { /* * Start Solution No. 10-100412-9447 */ // Set the Field ID //Start Solution No.: 10-091103-5969 DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() &pSrvrStmt->stmt: 0x%08x", 0)); //End Solution No.: 10-091103-5969 JNI_SetIntField(jenv, RSInfo, gJNICache.SPJRS_stmtIDFieldID, (jint)(0)); // Set the CTXHandle, this is same as the dialogId. DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() ctxHandle: 0x%08x", dialogueId)); JNI_SetIntField(jenv, RSInfo, gJNICache.SPJRS_ctxHandleFieldID, (jint)(dialogueId)); // Set the CLI statement closure status to the java variable DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() pSrvrStmt->isClosed: 0x%08x", JNI_TRUE)); //10-060831-8723 JNI_SetBooleanField(jenv, RSInfo, gJNICache.SPJRS_stmtClosedFieldID, (jint)(JNI_TRUE)); //10-060831-8723 /* * End Solution No. 10-100412-9447 */ // Variable initialized to zero in calling routine, so // if getting pSrvrStmt fails, just return w/o setting DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() getSrvrStmt() failed")); FUNCTION_RETURN_VOID((NULL)); } // Set the Field ID DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() &pSrvrStmt->stmt: 0x%08x", &(pSrvrStmt->stmt))); JNI_SetIntField(jenv, RSInfo, gJNICache.SPJRS_stmtIDFieldID, (jlong)&(pSrvrStmt->stmt)); // Get the Current Context Handle ctxHandle = pSrvrStmt->getContext(); if (ctxHandle == 0) // getContext() failed { // if ctxHandle = 0, call failed to obtain current context, rtn w/o setting DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() ctxHandle failed ctxHandle: 0x%08x", ctxHandle)); FUNCTION_RETURN_VOID((NULL)); } DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() ctxHandle: 0x%08x", ctxHandle)); JNI_SetIntField(jenv, RSInfo, gJNICache.SPJRS_ctxHandleFieldID, (jint)(ctxHandle)); // Set the CLI statement closure status to the java variable DEBUG_OUT(DEBUG_LEVEL_STMT,("getResultSetInfo() pSrvrStmt->isClosed: 0x%08x", pSrvrStmt->isClosed)); //10-060831-8723 JNI_SetBooleanField(jenv, RSInfo, gJNICache.SPJRS_stmtClosedFieldID, (jint)(pSrvrStmt->isClosed)); //10-060831-8723 FUNCTION_RETURN_VOID((NULL)); }
JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXStatement_closeUsingLabel (JNIEnv *jenv, jclass jclass, jstring server, jlong dialogueId, jstring stmtLabel, jboolean dropStmt) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXStatement_closeUsingLabel",("... stmtLabel=%s, dialogueId=0x%08x, dropStmt=%s", DebugJString(jenv,stmtLabel), dialogueId, DebugBoolStr(dropStmt))); ExceptionStruct exception_; long rowsAffected; ERROR_DESC_LIST_def sqlWarning; ERROR_DESC_def *error_desc_def; const char *nStmtLabel; if (stmtLabel) nStmtLabel = JNI_GetStringUTFChars(jenv,stmtLabel, NULL); else { throwSQLException(jenv, INVALID_STMT_LABEL_ERROR, NULL, "HY000"); FUNCTION_RETURN_VOID(("stmtLabel is NULL")); } odbc_SQLSvc_CloseUsingLabel_sme_(NULL, NULL, &exception_, dialogueId, (char *)nStmtLabel, (dropStmt ? SQL_DROP : SQL_CLOSE), &rowsAffected, &sqlWarning); if (stmtLabel) JNI_ReleaseStringUTFChars(jenv,stmtLabel, nStmtLabel); // Ignore setting warning since the input is jclass and not jobject switch (exception_.exception_nr) { case CEE_SUCCESS: break; case odbc_SQLSvc_Close_SQLError_exn_: 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)); }
//venu changed dialogueId and stmtId from int to long for 64 bit JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXStatement_cancel (JNIEnv *jenv, jobject jobj, jstring server, jlong dialogueId, jlong stmtId) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXStatement_cancel",("...")); ExceptionStruct exception_; ERROR_DESC_LIST_def sqlWarning; odbc_SQLSvc_CancelStatement_sme_(NULL, NULL, &exception_, dialogueId, stmtId, &sqlWarning); // Ignore setting warning since the input is jclass and not jobject switch (exception_.exception_nr) { case CEE_SUCCESS: break; case odbc_SQLSvc_CancelStatement_SQLError_exn_: throwSQLException(jenv, &exception_.u.SQLError); break; case odbc_SQLSvc_CancelStatement_ParamError_exn_: throwSQLException(jenv, PROGRAMMING_ERROR, exception_.u.ParamError.ParamDesc, "HY000"); break; case odbc_SQLSvc_CancelStatement_SQLInvalidHandle_exn_: throwSQLException(jenv, INVALID_HANDLE_ERROR, NULL, "HY000", exception_.u.SQLInvalidHandle.sqlcode); break; case odbc_SQLSvc_CancelStatement_InvalidConnection_exn_: default: // TFDS - This exceptions should not happen throwSQLException(jenv, PROGRAMMING_ERROR, NULL, "HY000", exception_.exception_nr); break; } FUNCTION_RETURN_VOID((NULL)); }
/* * Class: org_trafodion_jdbc_t2_T2Driver * Method: setCharsetEncodingOverride * Signature: (I)Ljava/lang/String; * Note: This function is a generic implementation to allow setting the * char set override encoding for the given charset (currently only the ISO88591 * column is allowed to be overriden) */ JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_T2Driver_setCharsetEncodingOverride(JNIEnv *jenv, jclass jcls, jint charset, jstring encodingOverride) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_T2Driver_setCharsetEncodingOverride", ("charset=%ld, encodingOverride=%s",charset, DebugJString(jenv,encodingOverride))); //Added for connect/disconnect impro. if (srvrGlobal == NULL) MEMORY_ALLOC_PERM(srvrGlobal,SRVR_GLOBAL_Def) for (int idx=0; idx<gJNICache.totalCharsets; idx++) if (charset == gJNICache.charsetInfo[idx].charset) { const char *nEncodingOverride = JNI_GetStringUTFChars(jenv,encodingOverride, NULL); if (strcmp(nEncodingOverride,defaultEncodingOption) == 0) { gJNICache.charsetInfo[idx].useDefaultEncoding = TRUE; } else { gJNICache.charsetInfo[idx].useDefaultEncoding = FALSE; } JNI_ReleaseStringUTFChars(jenv,encodingOverride, nEncodingOverride); } FUNCTION_RETURN_VOID((NULL)); }
SRVR_STMT_HDL::~SRVR_STMT_HDL() { FUNCTION_ENTRY("SRVR_STMT_HDL()::~SRVR_STMT_HDL",(NULL)); int retcode; cleanupAll(); #ifndef DISABLE_NOWAIT if (stmtInitForNowait) mutexCondDestroy(&cond, &mutex); #endif FUNCTION_RETURN_VOID((NULL)); }
//venu changed dialogueId and stmtId from int to long for 64 bit JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_SQLMXStatement_resetFetchSize (JNIEnv *, jobject, jlong dialogueId, jlong stmtId, jint fetchSize) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXStatement_resetFetchSize", ("... dialogueId=0x%08x, , stmtId=%ld, fetchSize=%ld", dialogueId, stmtId, fetchSize)); SRVR_STMT_HDL::resetFetchSize(dialogueId, stmtId, fetchSize); FUNCTION_RETURN_VOID((NULL)); }
/* * Class: org_trafodion_jdbc_t2_T2Driver * Method: setDefaultEncoding * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_T2Driver_setDefaultEncoding(JNIEnv *jenv, jclass jcls, jstring encoding) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_T2Driver_setDefaultEncoding",("encoding=%s", DebugJString(jenv,encoding))); gJNICache.defaultCharset = SQLCHARSETCODE_UNKNOWN; if (encoding) { const char *encoding_str = JNI_GetStringUTFChars(jenv,encoding, NULL); if (encoding_str) { gJNICache.defaultCharset = getCharset(encoding_str); JNI_ReleaseStringUTFChars(jenv,encoding, encoding_str); } } 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_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)); }
/* * Synchronous method function prototype for * operation 'odbc_SQLSvc_GetSQLCatalogs' */ void odbc_SQLSvc_GetSQLCatalogs_sme_( /* In */ void * objtag_ , /* In */ const CEE_handle_def *call_id_ , /* Out */ ExceptionStruct *exception_ , /* In */ long dialogueId , /* In */ short APIType , /* In */ const char *catalogNm , /* In */ const char *schemaNm , /* In */ const char *tableNm , /* In */ const char *tableTypeList , /* In */ const char *columnNm , /* In */ long columnType , /* In */ long rowIdScope , /* In */ long nullable , /* In */ long uniqueness , /* In */ long accuracy , /* In */ short sqlType , /* In */ unsigned long metadataId , /* Out */ char *catStmtLabel , /* Out */ SQLItemDescList_def *outputDesc , /* Out */ ERROR_DESC_LIST_def *sqlWarning , /* Out */ long *rowsAffected , /* Out */ SQLValueList_def *outputValueList , /* Out */ long *stmtId , /* In */ const char *fkcatalogNm , /* In */ const char *fkschemaNm , /* In */ const char *fktableNm) { FUNCTION_ENTRY("odbc_SQLSvc_GetSQLCatalogs_sme_",("")); DEBUG_OUT(DEBUG_LEVEL_ENTRY,(" %#x, %#x, %#x, %#x, %d, %s, %s, %s, %s, %s, %ld, %ld, %ld, %ld, %ld, %d, %#x, %#x, %#x", objtag_, call_id_, exception_, dialogueId, APIType, catalogNm, schemaNm, tableNm, tableTypeList, columnNm, columnType, rowIdScope, nullable, uniqueness, accuracy, sqlType, catStmtLabel, outputDesc, sqlWarning)); SRVRTRACE_ENTER(FILE_SME+14); enum CATAPI_TABLE_INDEX { COLUMNS = 0, DEFAULTS, INDEXES, KEYS, OBJECTS, OBJECTUID, TABLES, VIEWS, VIEWS_USAGE, VERSIONS }; char *smdCatAPITablesList[] = { "COLUMNS", "DEFAULTS", "INDEXES", "KEYS", "OBJECTS", "OBJECTUID", "TABLES", "VIEWS", "VIEWS_USAGE", "VERSIONS" }; const char *inputParam[16]; const char *tableParam[20]; short retCode; char tmpBuf[20]; char *odbcAppVersion = "3"; char *translationId = "3"; ExceptionStruct prepareException; CLEAR_EXCEPTION(prepareException); ExceptionStruct executeException; CLEAR_EXCEPTION(executeException); ExceptionStruct fetchException; CLEAR_EXCEPTION(fetchException); ExceptionStruct closeException; CLEAR_EXCEPTION(closeException); char expCatalogNm[MAX_ANSI_NAME_LEN+1]; char expSchemaNm[MAX_ANSI_NAME_LEN+1]; char expTableNm[MAX_ANSI_NAME_LEN+1]; char expColumnNm[MAX_ANSI_NAME_LEN+1]; char expProcNm[MAX_ANSI_NAME_LEN+1]; char catalogNmNoEsc[MAX_ANSI_NAME_LEN+1]; char schemaNmNoEsc[MAX_ANSI_NAME_LEN+1]; char tableNmNoEsc[MAX_ANSI_NAME_LEN+1]; char columnNmNoEsc[MAX_ANSI_NAME_LEN+1]; char procNmNoEsc[MAX_ANSI_NAME_LEN+1]; char tableName1[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char tableName2[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char tableName3[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char tableName4[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char tableName5[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char tableName6[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char tableName7[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char tableName8[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char SQLObjType[2]; char inParam1[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char inParam2[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; char inParam3[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; // catalog len + '.' + schema len + '.' + table len +'\0' char inParam4[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; // catalog len + '.' + schema len + '.' + table len +'\0' char schemaVersion[10]; // Holds SQL schema version from SQL_SCHEMAVERSION_ANSI_Q1 module call char fkstmtLabel[MAX_STMT_LABEL_LEN+1]; // Used for FK methods long rowsMPFetched; // # of tables to check for MP metadata long rowsFKFetched; // # of rows fetched from foreign keys method query 1 BOOL queryMP = FALSE; // Flag whether to pull MP metadata SQLValueList_def tempOutputValueList; // Intermediate and temp output value lists // Null out tempOutputValueList CLEAR_LIST(tempOutputValueList); long curRowNo = 0; long numOfCols = 0; long curColNo = 0; char schemaNmAct[MAX_ANSI_NAME_LEN+1]; char tableNmAct[MAX_ANSI_NAME_LEN+1]; char colNmAct[MAX_ANSI_NAME_LEN+1]; char ordinalAct[10]; char obuidAct[MAX_ANSI_NAME_LEN+1]; char riuidAct[MAX_ANSI_NAME_LEN+1]; short sqlStmtType; SQLItemDescList_def lc_outputDesc; BOOL tableViewGiven = FALSE; BOOL systemTableGiven = FALSE; short namelen; SQLValue_def *SQLValue; char userCatalogNm[MAX_ANSI_NAME_LEN+1]; char guardianNm[36]; // 8+1+8+1+8+1+8+1 char inParam[MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+MAX_ANSI_NAME_LEN+3]; // catalog len + '.' + schema len + '.' + table len +'\0' char MapDataType[2] = "0"; tmpBuf[0] = '\0'; fkstmtLabel[0] = '\0'; userCatalogNm[0] = '\0'; char catStmtLabelNew[128] = {'\0'}; // Trying to support max module name length inputParam[0] = srvrGlobal->SystemCatalog; if (catalogNm == NULL) strcpy(catalogNmNoEsc,""); //strcpy(catalogNmNoEsc,srvrGlobal->DefaultCatalog); // There is an OR condition with the catalog so it can be "" else strcpy(catalogNmNoEsc, catalogNm); inputParam[1] = catalogNmNoEsc; if (schemaNm == NULL ) strcpy(schemaNmNoEsc,"%"); else strcpy(schemaNmNoEsc, schemaNm); if (schemaNm != NULL ) { convertWildcardNoEsc(metadataId, FALSE, schemaNm, schemaNmNoEsc); convertWildcard(metadataId, TRUE, schemaNm, expSchemaNm); } inputParam[2] = schemaNmNoEsc; inputParam[3] = expSchemaNm; inputParam[4] = NULL; sqlStmtType = TYPE_SELECT; DEBUG_OUT(DEBUG_LEVEL_METADATA,("SQL_SCHEMAVERSION_NEW_ANSI_Q1 tableParams= |%s|%s| inputParams= |%s|", tableParam[0],tableParam[1], inputParam[0])); if (APIType != SQL_TXN_ISOLATION) { retCode = executeAndFetchSMDQuery(objtag_, call_id_, dialogueId, APIType, "SQL_CATALOG_API", sqlStmtType, &tableParam[0], &inputParam[0], catalogNm, schemaNm, tableNm, columnNm, tableTypeList, metadataId, outputDesc, &executeException, &fetchException, sqlWarning, rowsAffected, outputValueList, stmtId); if (retCode != CEE_SUCCESS && writeServerException(retCode,exception_,&prepareException,&executeException,&fetchException) != TRUE) { odbc_SQLSvc_Close_sme_(objtag_, call_id_, &closeException, dialogueId, *stmtId, SQL_DROP, rowsAffected, sqlWarning); FUNCTION_RETURN_VOID(("executeAndFetchSMDQuery() and writeServerException() Failed")); } if (retCode == FETCH_EXCEPTION && fetchException.exception_nr == odbc_SQLSvc_FetchN_SQLNoDataFound_exn_) { odbc_SQLSvc_Close_sme_(objtag_, call_id_, &closeException, dialogueId, *stmtId, SQL_DROP, rowsAffected, sqlWarning); FUNCTION_RETURN_VOID(("executeAndFetchSMDQuery() FETCH_EXCEPTION - SQLNoDataFound Expected")); } SQLValue = (SQLValue_def *)outputValueList->_buffer; if (SQLValue->dataInd == -1) //does not come here { inputParam[0] = srvrGlobal->SystemCatalog; inputParam[2] = "SYSTEM_SCHEMA"; memset(outputValueList, NULL, sizeof(SQLValueList_def)); retCode = executeAndFetchSMDQuery(objtag_, call_id_, dialogueId, APIType, "SQL_SCHEMAVERSION_NEW_ANSI_Q1", sqlStmtType, &tableParam[0], &inputParam[0], catalogNm, schemaNm, tableNm, columnNm, tableTypeList, metadataId, outputDesc, &executeException, &fetchException, sqlWarning, rowsAffected, outputValueList, stmtId); if (retCode != CEE_SUCCESS && writeServerException(retCode,exception_,&prepareException,&executeException,&fetchException) != TRUE) { odbc_SQLSvc_Close_sme_(objtag_, call_id_, &closeException, dialogueId, *stmtId, SQL_DROP, rowsAffected, sqlWarning); FUNCTION_RETURN_VOID(("executeAndFetchSMDQuery() and writeServerException() Failed")); } if (retCode == FETCH_EXCEPTION && fetchException.exception_nr == odbc_SQLSvc_FetchN_SQLNoDataFound_exn_) { odbc_SQLSvc_Close_sme_(objtag_, call_id_, &closeException, dialogueId, *stmtId, SQL_DROP, rowsAffected, sqlWarning); FUNCTION_RETURN_VOID(("executeAndFetchSMDQuery() and writeServerException() Failed")); } SQLValue = (SQLValue_def *)outputValueList->_buffer; if (SQLValue->dataInd == -1) { exception_->exception_nr = odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_; exception_->u.ParamError.ParamDesc = SQLSVC_EXCEPTION_INVALID_SCHEMA_VERSION; FUNCTION_RETURN_VOID(("SQLValue->dataInd == -1")); } } } 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)); }
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)); }
// MFC - added two parameters to set the MFC on/off and the directory JNIEXPORT void JNICALL Java_org_trafodion_jdbc_t2_T2Driver_SQLMXInitialize(JNIEnv *jenv, jclass cls, jstring language, jint nowaitOn, jstring moduleCaching, jstring compiledModuleLocation) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_T2Driver_SQLMXInitialize",("language=%s, nowaitOn=%ld", DebugJString(jenv,language), nowaitOn)); const char *nLanguage; // static GlobalInformation *globalInfo = new GlobalInformation(); //MFC const char *nModuleCaching; const char *nCompiledModuleLocation; /* // Seaquest related - Linux port int argc = 0; char *argv[] = {"AAA"}; //argv[0] = NULL; // Initialize seabed int sbResult; char buffer[FILENAME_MAX] = {0}; bzero(buffer, sizeof(buffer)); sbResult = file_init_attach(&argc, &argv, true, buffer); if(sbResult != XZFIL_ERR_OK){ abort(); } sbResult = file_mon_process_startup(true); if(sbResult != XZFIL_ERR_OK){ abort(); } msg_mon_enable_mon_messages(true); // End Seaquest related */ if (!driverVersionChecked) { printf("JDBC Library Version Error - Jar: Unknown Jni: %s\n", driverVproc); abort(); } GlobalInformation::setSQLMX_Version(); if (srvrGlobal == NULL) MEMORY_ALLOC_PERM(srvrGlobal,SRVR_GLOBAL_Def) else { if (srvrGlobal->boolFlgforInitialization == 1) FUNCTION_RETURN_VOID(("Already Initialized")); } if (! cacheJNIObjects(jenv)) FUNCTION_RETURN_VOID(("cacheJNIObjects() failed")); #ifdef NSK_PLATFORM // Linux port if (language) { nLanguage = JNI_GetStringUTFChars(jenv,language, NULL); if (strcmp(nLanguage, "ja") == 0) { srvrGlobal->clientLCID = MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT); srvrGlobal->clientErrorLCID = srvrGlobal->clientLCID; } else if (strcmp(nLanguage, "en") == 0) { srvrGlobal->clientLCID = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT); srvrGlobal->clientErrorLCID = srvrGlobal->clientLCID; } else { srvrGlobal->clientLCID = LANG_NEUTRAL; srvrGlobal->clientErrorLCID = LANG_NEUTRAL; } JNI_ReleaseStringUTFChars(jenv,language, nLanguage); } else { srvrGlobal->clientLCID = LANG_NEUTRAL; srvrGlobal->clientErrorLCID = LANG_NEUTRAL; } #endif srvrGlobal->dialogueId = 0; // DialogueId is set to zero now // Linux port - Nowait support is set to OFF for now. // nowaitOn = 0; // Should come command line or JDBC properties switch (nowaitOn) { case 0: srvrGlobal->nowaitOn = 0; break; case 1: srvrGlobal->nowaitOn = 1; break; case 2: srvrGlobal->nowaitOn = 2; break; default: srvrGlobal->nowaitOn = 0; break; } #ifdef NSK_PLATFORM // Linux port // setup MP system catalog name if (envGetSystemCatalogName (&srvrGlobal->NskSystemCatalogName[0]) != TRUE) { throwSQLException(jenv, SYSTEM_CATALOG_ERROR, NULL, "HY000", 0); FUNCTION_RETURN_VOID(("envGetSystemCatalogName() failed")); } // setup MX system catalog name if (envGetMXSystemCatalogName (&srvrGlobal->SystemCatalog[0]) != TRUE) { throwSQLException(jenv, SYSTEM_CATALOG_ERROR, NULL, "HY000", 0); FUNCTION_RETURN_VOID(("envGetMXSystemCatalogName() failed")); } #endif // MFC - set the srvrGlobal variables w.r.t the properties - start srvrGlobal->moduleCaching=0; if (moduleCaching) { nModuleCaching = JNI_GetStringUTFChars(jenv,moduleCaching, NULL); if (strcmp(nModuleCaching,"ON") == 0) srvrGlobal->moduleCaching=1; //Soln. No.: 10-110927-9875 - fix memory leak JNI_ReleaseStringUTFChars(jenv,moduleCaching, nModuleCaching); } if (srvrGlobal->moduleCaching == 1) { memset(srvrGlobal->CurrentCatalog, '\0', 129); memset(srvrGlobal->CurrentSchema, '\0', 129); memset(srvrGlobal->compiledModuleLocation, '\0', 100); if (compiledModuleLocation == NULL) { strcpy(srvrGlobal->compiledModuleLocation,"/usr/tandem/sqlmx/USERMODULES"); } else { nCompiledModuleLocation = JNI_GetStringUTFChars(jenv,compiledModuleLocation, NULL); strcpy(srvrGlobal->compiledModuleLocation,nCompiledModuleLocation); //Soln. No.: 10-110927-9875 - fix memory leak JNI_ReleaseStringUTFChars(jenv,compiledModuleLocation, nCompiledModuleLocation); if(srvrGlobal->compiledModuleLocation[0] != '/') { printf("The directory provided for option \"compiledmodulelocation\" must be an absolute path.\n"); abort(); } int nDirExists = access(srvrGlobal->compiledModuleLocation, F_OK); if(nDirExists != 0) { printf("The directory provided for option \"compiledmodulelocation\" does not exist.\n"); abort(); } nDirExists = access(srvrGlobal->compiledModuleLocation, W_OK); if(nDirExists != 0) { printf("The directory provided for option \"compiledmodulelocation\" does not have \"write\" permission.\n"); abort(); } if(srvrGlobal->compiledModuleLocation[strlen(srvrGlobal->compiledModuleLocation)-1] == '/') { srvrGlobal->compiledModuleLocation[strlen(srvrGlobal->compiledModuleLocation)-1] = '\0'; } } } srvrGlobal->boolFlgforInitialization = 1; // MFC set the srvrGlobal variables w.r.t the properties - end FUNCTION_RETURN_VOID((NULL)); }
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)); }
/* 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)); }
SRVR_STMT_HDL::SRVR_STMT_HDL() { FUNCTION_ENTRY("SRVR_STMT_HDL()::SRVR_STMT_HDL",(NULL)); SRVR_STMT_HDL(0); FUNCTION_RETURN_VOID((NULL)); }
SRVR_STMT_HDL::SRVR_STMT_HDL(long inDialogueId) { FUNCTION_ENTRY("SRVR_STMT_HDL::SRVR_STMT_HDL",("inDialogueId=%ld)",inDialogueId)); cursorName[0] = '\0'; previousCursorName[0] = '\0'; stmtName[0] = '\0'; paramCount = 0; columnCount = 0; SqlQueryStatementType = INVALID_SQL_QUERY_STMT_TYPE; stmtType = EXTERNAL_STMT; inputDescVarBuffer = NULL; outputDescVarBuffer = NULL; inputDescVarBufferLen = 0; outputDescVarBufferLen = 0; endOfData = FALSE; // The following were added for SPJRS support isSPJRS = FALSE; RSIndex = 0; RSMax = 0; currentMethod = UNKNOWN_METHOD; asyncThread = NULL; queryTimeoutThread = NULL; threadStatus = SQL_SUCCESS; threadId = 0; threadReturnCode = SQL_SUCCESS; sqlAsyncEnable = SQL_ASYNC_ENABLE_OFF; queryTimeout = 0; sqlString.dataValue._buffer = NULL; sqlString.dataValue._length = 0; inputRowCnt = 0; maxRowCnt = 0; sqlStmtType = TYPE_UNKNOWN; freeResourceOpt = SQL_CLOSE; inputValueList._length = 0; inputValueList._buffer = NULL; estimatedCost = 0; rowsAffected = 0; inputDescList._length = 0; inputDescList._buffer = NULL; outputDescList._length = 0; outputDescList._buffer = NULL; CLEAR_WARNING(sqlWarning); CLEAR_ERROR(sqlError); outputValueList._length = 0; outputValueList._buffer = NULL; outputValueVarBuffer = NULL; inputValueVarBuffer = NULL; clientLCID = srvrGlobal->clientLCID; rowCount._length = 0; rowCount._buffer = NULL; isReadFromModule = FALSE; moduleName[0] = '\0'; inputDescName[0] = '\0'; outputDescName[0] = '\0'; isClosed = TRUE; IPD = NULL; IRD = NULL; useDefaultDesc = FALSE; dialogueId = inDialogueId; nowaitRetcode = SQL_SUCCESS; holdability = CLOSE_CURSORS_AT_COMMIT; fetchQuadEntries = 0; fetchRowsetSize = 0; fetchQuadField = NULL; batchQuadEntries = 0; batchRowsetSize = 0; batchQuadField = NULL; inputDescParamOffset = 0; batchMaxRowsetSize = 0; stmtInitForNowait = FALSE; FUNCTION_RETURN_VOID((NULL)); }
void AssembleSqlString(SMD_SELECT_TABLE *smdSelectTable, const char *catalogNm, const char *locationNm, char *sqlString) { FUNCTION_ENTRY("AssembleSqlString",("...")); SMD_SELECT_TABLE *lc_smdSelectTable; lc_smdSelectTable = smdSelectTable; sqlString[0] = '\0'; while(lc_smdSelectTable->lineID != END_OF_TABLE ) { switch (lc_smdSelectTable->lineID) { case STRING_TYPE: strcat(sqlString, lc_smdSelectTable->textLine); break; case TABLE_TYPE: strcat(sqlString, smdTablesList[lc_smdSelectTable->index]); break; case SCHEMA_TYPE: strcat(sqlString, smdSchemaList[lc_smdSelectTable->index]); break; case CATALOG_TYPE: if( catalogNm != NULL && catalogNm[ 0 ] != '\0' ) { strcat(sqlString, "trim('"); strcat(sqlString, catalogNm); //strcat(sqlString, "'),"); // shirley 11/13/97 strcat(sqlString, "') TABLE_QUALIFIER,"); // shirley 11/13/97 } else //strcat(sqlString, "'',"); // shirley 11/13/97 strcat(sqlString, "'' TABLE_QUALIFIER,"); // shirley 11/13/97 break; case CATALOG_TYPE_DOT: if( catalogNm != NULL && catalogNm[ 0 ] != '\0' ) { strcat(sqlString, catalogNm); strcat(sqlString, "."); } break; case LOCATION_TYPE: if( locationNm != NULL && locationNm[ 0 ] != '\0' ) { strcat(sqlString, " LOCATION "); strcat(sqlString, locationNm); } break; #ifdef NSK_PLATFORM case NSK_CLUSTER_TYPE: if( catalogNm != NULL && catalogNm[ 0 ] != '\0' ) { strcat(sqlString, catalogNm); strcat(sqlString, "."); } break; case NSK_SHORTANSI_CATALOG_NAME: catalogsTableNm[0] = '\0'; translateNSKtoShortAnsiFormat(&catalogsTableNm[0], (char *)catalogNm); strcat(sqlString,catalogsTableNm); break; case NSK_CATALOGS_TABLE_LOCATION: char temp[MAX_DBNAME_LEN+1]; unsigned int i,j,k; catalogsTableNm[0] = '\0'; temp[0] = '\0'; envGetCatalogsTable(temp); j = 0; k = 0; for (i = 0; i < strlen(temp); i++) { if (temp[i] == '.') { if (k == 1) { catalogsTableNm[j++] = temp[i]; catalogsTableNm[j++] = '"'; } else if (k == 2) { catalogsTableNm[j++] = '"'; catalogsTableNm[j++] = temp[i]; } else { catalogsTableNm[j++] = temp[i]; } k++; } else { catalogsTableNm[j++] = temp[i]; } } catalogsTableNm[j] = '\0'; strcat(sqlString, catalogsTableNm); break; #endif default: break; } lc_smdSelectTable++; } FUNCTION_RETURN_VOID((NULL)); } // End of Function
//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)); }