美文网首页JavaMVC框架
MyBatis在操作Oracle数据库时,插入Null提示无效字

MyBatis在操作Oracle数据库时,插入Null提示无效字

作者: Belmode | 来源:发表于2018-06-26 11:44 被阅读2次

这是因为mybatis在解释null默认转换为数据Other类型,MySQL认识,但是Oracle不认识,所以报错。

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

两种解决方法

  1. 在插入语句中的字段的表达式括号内加入jdbc类型


2.在Mybatis全局配置文件中加入setting : jdbcTypeForNull

    <settings>
        <setting name="jdbcTypeForNull" value="NULL"/>
    </settings>

问题即可解决

相关文章

网友评论

    本文标题:MyBatis在操作Oracle数据库时,插入Null提示无效字

    本文链接:https://www.haomeiwen.com/subject/uxbpyftx.html