Error setting null for parameter #6 with JdbcType OTHER . Try setting a different JdbcType for this

简介: Error setting null for parameter #6 with JdbcType OTHER . Try setting a different JdbcType for this

控制台报错信息如下

控制台报错信息如下:

Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #6 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型]

原因

这是我们在向mybatis中对oracle数据库执行更新或新增操作时,添加的值为null导致的。如果在mysql中则不会出现这种错误。

在mybatis官方文档中,setting中有这么一条属性 jdbcTypeForNull

可以看到,当没有为参数指定JDBC类型时,空值使用默认的jdbc类型,像oracle数据库,我们插入空值时,需要指定类型。

解决

insert语句中,增加jdbcType

例如:

#{name,jdbcType=VARCHAR}

目录
相关文章
|
2月前
|
Java
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
54 1
|
8月前
|
编译器
error TS2322 Type ‘string null‘ is not assignable to type ‘string undefined‘.
error TS2322 Type ‘string null‘ is not assignable to type ‘string undefined‘.
|
2月前
|
开发工具
gdbusauth.c:1302:11: error: ‘%s’ directive argument is null
gdbusauth.c:1302:11: error: ‘%s’ directive argument is null
105 0
|
9月前
|
XML Java 数据库连接
MyBatis参数映射问题解决教程: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 wit
MyBatis参数映射问题解决教程: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 wit
529 1
|
8月前
|
SQL 关系型数据库 数据库
DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null
DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null
213 0
error • The parameter ‘name‘ can‘t have a value of ‘null‘ because of its type错误
error • The parameter ‘name‘ can‘t have a value of ‘null‘ because of its type错误
Maven: java.lang.NullPointerException: inStream parameter is null
Maven: java.lang.NullPointerException: inStream parameter is null
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
|
2月前
|
SQL 关系型数据库 MySQL
实时计算 Flink版产品使用合集之从MySQL同步数据到Doris时,历史数据时间字段显示为null,而增量数据部分的时间类型字段正常显示的原因是什么
实时计算Flink版作为一种强大的流处理和批处理统一的计算框架,广泛应用于各种需要实时数据处理和分析的场景。实时计算Flink版通常结合SQL接口、DataStreamAPI、以及与上下游数据源和存储系统的丰富连接器,提供了一套全面的解决方案,以应对各种实时计算需求。其低延迟、高吞吐、容错性强的特点,使其成为众多企业和组织实时数据处理首选的技术平台。以下是实时计算Flink版的一些典型使用合集。
|
2月前
|
SQL 关系型数据库 MySQL
python在mysql中插入或者更新null空值
这段代码是Python操作MySQL数据库的示例。它执行SQL查询从表`a_kuakao_school`中选取`id`,`university_id`和`grade`,当`university_id`大于0时按升序排列。然后遍历结果,根据`row[4]`的值决定`grade`是否为`NULL`。若不为空,`grade`被格式化为字符串;否则,设为`NULL`。接着构造UPDATE语句更新`university`表中对应`id`的`grade`值,并提交事务。重要的是,字符串`NULL`不应加引号,否则更新会失败。
66 2