JNIEXPORT jint JNICALL Java_org_trafodion_jdbc_t2_T2Driver_getDatabaseMajorVersionJNI(JNIEnv *jenv, jclass jcls) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_T2Driver_getDatabaseMajorVersionJNI",("...")); int databaseMajorVersion = TRAFODION_JDBCT2_VER_MAJOR; FUNCTION_RETURN_NUMERIC(databaseMajorVersion, ("Database Major Version = %d", databaseMajorVersion)); }
//venu changed dialogueId and stmtId from int to long for 64 bit JNIEXPORT jint JNICALL Java_org_trafodion_jdbc_t2_SQLMXStatement_close (JNIEnv *jenv, jclass jclass, jstring server, jlong dialogueId, jlong stmtId, jboolean dropStmt) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_SQLMXStatement_close", ("... dialogueId=0x%08x, stmtId=%ld, dropStmt=%s", dialogueId, stmtId, DebugBoolStr(dropStmt))); ExceptionStruct exception_; long rowsAffected; ERROR_DESC_LIST_def sqlWarning; jint retcode = -1; // 0 - Success, -1 = failure // 1= Cursor Not Found ERROR_DESC_def *error_desc_def; odbc_SQLSvc_Close_sme_(NULL, NULL, &exception_, dialogueId, stmtId, (dropStmt ? SQL_DROP : SQL_CLOSE), &rowsAffected, &sqlWarning); // Ignore setting warning since the input is jclass and not jobject switch (exception_.exception_nr) { case CEE_SUCCESS: retcode = 0; 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) retcode = 1; 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_NUMERIC(retcode,(NULL)); }
JNIEXPORT jint JNICALL Java_org_trafodion_jdbc_t2_T2Driver_getDatabaseMinorVersionJNI(JNIEnv *jenv, jclass jcls) { FUNCTION_ENTRY("Java_org_trafodion_jdbc_t2_T2Driver_getDatabaseMinorVersionJNI",("...")); // This method only supports SQL R2.0 and SQL R2.1 // Update needed when SQL provides version directly int databaseMinorVersion; short version = 0; short ret = 0; // ret = GETSQLMXSYSTEMVERSION(&version); //if Return ocde is error, considered db minor version as 0 switch (version) { case 3000: databaseMinorVersion = 0; break; case 3100: databaseMinorVersion = 1; break; //Added for R3.2 case 3200: databaseMinorVersion = 2; break; case 3300: databaseMinorVersion = 3; break; case 3400: databaseMinorVersion = 4; break; default: databaseMinorVersion = 0; } FUNCTION_RETURN_NUMERIC(databaseMinorVersion, ("Database Minor Version = %d", databaseMinorVersion)); }
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))); }
long SQLMXStatement_SUCCESS_NO_INFO(void) { FUNCTION_ENTRY("SQLMXStatement_SUCCESS_NO_INFO",(NULL)); FUNCTION_RETURN_NUMERIC(org_trafodion_jdbc_t2_SQLMXStatement_JNI_SUCCESS_NO_INFO, ("org_trafodion_jdbc_t2_SQLMXStatement_JNI_SUCCESS_NO_INFO")); }
long SQLMXStatement_EXECUTE_FAILED(void) { FUNCTION_ENTRY("SQLMXStatement_EXECUTE_FAILED",(NULL)); FUNCTION_RETURN_NUMERIC(org_trafodion_jdbc_t2_SQLMXStatement_JNI_EXECUTE_FAILED, ("org_trafodion_jdbc_t2_SQLMXStatement_JNI_EXECUTE_FAILED")); }