From dbba27cd3dc8507f8bbc67631e5dba2873167247 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 19 Oct 2021 15:52:48 +0800 Subject: [PATCH] fixed JNI connector --- src/client/src/TSDBJNIConnector.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 0e08fd26a4..50fe51e7da 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -100,8 +100,6 @@ jmethodID g_blockdataSetNumOfColsFp; #define JNI_FETCH_END -6 #define JNI_OUT_OF_MEMORY -7 -#define JNI_ERR_MSG_BUF_LEN 50 - static void jniGetGlobalMethod(JNIEnv *env) { // make sure init function executed once switch (atomic_val_compare_exchange_32(&__init, 0, 1)) { @@ -1055,10 +1053,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI } JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JNIEnv *env, jobject jobj, - jobjectArray lines, jlong conn) { - int a_lines = 0; - char errMsg[JNI_ERR_MSG_BUF_LEN] = {0}; - + jobjectArray lines, jlong conn, + jint protocol, jint precision) { TAOS *taos = (TAOS *)conn; if (taos == NULL) { jniError("jobj:%p, connection already closed", jobj); @@ -1076,7 +1072,8 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); } - int code = taos_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL, "ms", &a_lines, errMsg, JNI_ERR_MSG_BUF_LEN); + SSqlObj* result = (SSqlObj*)taos_schemaless_insert(taos, c_lines, numLines, protocol, precision); + int code = taos_errno(result); for (int i = 0; i < numLines; ++i) { jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); @@ -1085,9 +1082,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J tfree(c_lines); if (code != TSDB_CODE_SUCCESS) { - jniError("jobj:%p, conn:%p, code:%s, affected lines:%d", jobj, taos, errMsg, a_lines); + jniError("jobj:%p, conn:%p, code:%s, msg:%s", jobj, taos, tstrerror(code), taos_errstr(result)); return JNI_TDENGINE_ERROR; } - return code; + + return (jlong)result; } -- GitLab