//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_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)); }
//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)); }