Skip to content

Commit 157c4ec

Browse files
authored
fix: set varbinary/geometry compatibility issue (#271)
1 parent 560ec93 commit 157c4ec

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

deploy-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.taosdata.jdbc</groupId>
77
<artifactId>taos-jdbcdriver</artifactId>
8-
<version>3.7.0</version>
8+
<version>3.7.1</version>
99
<packaging>jar</packaging>
1010

1111
<name>JDBCDriver</name>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.taosdata.jdbc</groupId>
55
<artifactId>taos-jdbcdriver</artifactId>
6-
<version>3.7.0</version>
6+
<version>3.7.1</version>
77

88
<packaging>jar</packaging>
99
<name>JDBCDriver</name>

src/main/java/com/taosdata/jdbc/ws/AbsWSPreparedStatement.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,15 @@ public void setString(int parameterIndex, String x) throws SQLException {
482482
public void setBytes(int parameterIndex, byte[] x) throws SQLException {
483483
colOrderedMap.put(parameterIndex, new Column(x, TSDB_DATA_TYPE_BINARY, parameterIndex));
484484
}
485+
486+
public void setVarbinary(int parameterIndex, byte[] x) throws SQLException {
487+
setBytes(parameterIndex, x);
488+
}
489+
490+
public void setGeometry(int parameterIndex, byte[] x) throws SQLException {
491+
setBytes(parameterIndex, x);
492+
}
493+
485494
@Override
486495
public void setDate(int parameterIndex, Date x) throws SQLException {
487496
if (x == null) {

src/test/java/com/taosdata/jdbc/ws/stmt/WsPstmtAllTypeTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.taosdata.jdbc.ws.stmt;
22

33
import com.taosdata.jdbc.TSDBConstants;
4-
import com.taosdata.jdbc.common.TDBlob;
54
import com.taosdata.jdbc.utils.SpecifyAddress;
65
import com.taosdata.jdbc.utils.StringUtils;
76
import com.taosdata.jdbc.utils.TestUtils;
@@ -147,7 +146,7 @@ public void testExecuteUpdate2() throws SQLException {
147146
@Test
148147
public void testExecuteCriticalValue() throws SQLException {
149148
String sql = "insert into " + db_name + "." + tableName + " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
150-
PreparedStatement statement = connection.prepareStatement(sql);
149+
TSWSPreparedStatement statement = connection.prepareStatement(sql).unwrap(TSWSPreparedStatement.class);
151150
statement.setTimestamp(1, new Timestamp(0));
152151
statement.setByte(2, (byte) 127);
153152
statement.setShort(3, (short) 32767);
@@ -159,8 +158,8 @@ public void testExecuteCriticalValue() throws SQLException {
159158
statement.setString(9, "ABC");
160159
statement.setNString(10, "涛思数据");
161160
statement.setString(11, "陶");
162-
statement.setBytes(12, expectedVarBinary);
163-
statement.setBytes(13, expectedGeometry);
161+
statement.setVarbinary(12, expectedVarBinary);
162+
statement.setGeometry(13, expectedGeometry);
164163
statement.setShort(14, TSDBConstants.MAX_UNSIGNED_BYTE);
165164
statement.setInt(15, TSDBConstants.MAX_UNSIGNED_SHORT);
166165
statement.setLong(16, TSDBConstants.MAX_UNSIGNED_INT);

0 commit comments

Comments
 (0)