From 7ea4be8ae26b6977fcd9e0cd25fe139e4bafaca1 Mon Sep 17 00:00:00 2001 From: sheyanjie-qq <249478495@qq.com> Date: Sun, 27 Oct 2024 12:06:34 +0800 Subject: [PATCH] fix native resultset get int on float type error --- src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java | 4 +++- .../java/com/taosdata/jdbc/block/TSDBBlockResultSetTest.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java b/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java index 45ce7352..d4f34777 100644 --- a/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java +++ b/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java @@ -381,7 +381,9 @@ public int getInt(int col) throws SQLException { return ((Long) ((Timestamp) obj).getTime()).intValue(); } - case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_FLOAT:{ + return ((Float) obj).intValue(); + } case TSDB_DATA_TYPE_DOUBLE: { return ((Double) obj).intValue(); } diff --git a/src/test/java/com/taosdata/jdbc/block/TSDBBlockResultSetTest.java b/src/test/java/com/taosdata/jdbc/block/TSDBBlockResultSetTest.java index 2bff4468..2122556e 100644 --- a/src/test/java/com/taosdata/jdbc/block/TSDBBlockResultSetTest.java +++ b/src/test/java/com/taosdata/jdbc/block/TSDBBlockResultSetTest.java @@ -70,6 +70,9 @@ public void getInt() throws SQLException { Assert.assertEquals(1, f2); f2 = rs.getInt(2); Assert.assertEquals(1, f2); + + f2 = rs.getInt(4); + Assert.assertEquals(3, f2); } @Test