From ea3406d7b61a3b3b65b30c768cadca36136f90e7 Mon Sep 17 00:00:00 2001 From: huolibo Date: Thu, 24 Mar 2022 15:41:54 +0800 Subject: [PATCH] [TD-14055]: adjust the method of obtaining values (#10958) --- src/client/src/TSDBJNIConnector.c | 13 ++++--------- .../com/taosdata/jdbc/TSDBResultSetBlockData.java | 3 ++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 49c7008947..c7d328bf1d 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -573,8 +573,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI return code; } - TAOS_RES *tres = (TAOS_RES *)res; - TAOS_FIELD *fields = taos_fetch_fields(tres); + TAOS_RES *tres = (TAOS_RES *)res; int32_t numOfFields = taos_num_fields(tres); assert(numOfFields > 0); @@ -596,14 +595,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfRowsFp, (jint)numOfRows); (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfColsFp, (jint)numOfFields); + int32_t *field = taos_fetch_lengths(tres); for (int i = 0; i < numOfFields; i++) { - int bytes = fields[i].bytes; - - if (fields[i].type == TSDB_DATA_TYPE_BINARY || fields[i].type == TSDB_DATA_TYPE_NCHAR) { - bytes += 2; - } - (*env)->CallVoidMethod(env, rowobj, g_blockdataSetByteArrayFp, i, bytes * numOfRows, - jniFromNCharToByteArray(env, (char *)row[i], bytes * numOfRows)); + (*env)->CallVoidMethod(env, rowobj, g_blockdataSetByteArrayFp, i, field[i] * numOfRows, + jniFromNCharToByteArray(env, (char *)row[i], field[i] * numOfRows)); } return JNI_SUCCESS; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java index e404db64e3..3e530a523a 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java @@ -408,7 +408,8 @@ public class TSDBResultSetBlockData { case TSDBConstants.TSDB_DATA_TYPE_NCHAR: { ByteBuffer bb = (ByteBuffer) this.colData.get(col); - bb.position((fieldSize + BINARY_LENGTH_OFFSET) * this.rowIndex); +// bb.position((fieldSize * 4 + 2 + 1) * this.rowIndex); + bb.position(bb.capacity() / numOfRows * this.rowIndex); int length = bb.getShort(); byte[] dest = new byte[length]; bb.get(dest, 0, length); -- GitLab