使用Websocket Insert数据时报 unsupported data type : 21

【TDengine 使用环境】
生产环境 /测试/ Poc/预生产环境

【TDengine 版本】3.3.8.4

【操作系统以及版本】

【部署方式】容器/非容器部署

【遇到的问题:问题现象及影响】

使用RS 连接方式时没有任何问题,使用WS时报如下错误

jdbc 连接器的版本是多少?估计是太低了,先从maven仓库拉一下最新版本吧。

3.7.8 也不算很低了

0x2303 invalid variables 参数不合法 请检查相应接口规范,调整参数类型及大小

错误码是这个,可以对照下表结构,看下是否是匹配的。

我得数据类型很简单 就String Integer Long Float, ts的数据类型是Long,Float 对应数据库的DECIMAL,其他都对应。

如果我把java对象的Float改成 BigDecimal 则有如下报错

SQL: INSERT INTO inverter ( tbname, time, sn, pv_power, energy_today, energy_total, load_power, charge_power, discharge_power, soc, grid_import_power, grid_export_power, battery_power, inverter_temp, grid_frequency, grid_power, time_point ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )

Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘pvPower’, mode=IN, javaType=class java.math.BigDecimal, jdbcType=NUMERIC, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType NUMERIC . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLFeatureNotSupportedException: this operation is NOT supported currently!

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:99)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:347)
at jdk.proxy2/jdk.proxy2.$Proxy145.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:156)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:93)
at jdk.proxy2/jdk.proxy2.$Proxy146.insertInverter1(Unknown Source)

可以帮忙看看原因吗,RS连接不支持查询BigDecimal,WS连接不支持写入BigDecimal。很难开发啊!

ws 是支持的。

Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘pvPower’, mode=IN, javaType=class java.math.BigDecimal, jdbcType=DECIMAL, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType DECIMAL . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLFeatureNotSupportedException: this operation is NOT supported currently!

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:99)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:347)
at jdk.proxy2/jdk.proxy2.$Proxy145.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:156)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:93)
at jdk.proxy2/jdk.proxy2.$Proxy146.insertInverter1(Unknown Source)

如果使用Decimal 作为jdbcType 则报如上的错误。

No enum constant org.apache.ibatis.type.JdbcType.BigDecimal

如果使用BigDecimal 则无法识别BigDecimal

Caused by: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘pvPower’, mode=IN, javaType=class java.math.BigDecimal, jdbcType=null, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLFeatureNotSupportedException: this operation is NOT supported currently!
at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:92)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:97)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:65)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)

如果我不指定类型则报如上错误。

所以我该如何使用WebSocket连接器写入DECIMAL数据类型。

而且我也下载了你们的demo 里面没有关于使用DECIMAL的例子,因此需要帮助 谢谢。

目前还不支持 参数绑定方式写入 Decimal。我们会很快支持。你可以用 sql 写入,请参考

好的 谢谢 明白了。