Cause: java.sql.SQLException: 无效的列类型: 1111

当在MyBatis-Plus中使用Oracle数据库进行查询时,如果参数为null,可能会遇到内部错误,状态码500。错误信息提示无效的列类型。解决方法包括在Java代码中增加null判断,或者在XML映射文件中为参数指定jdbcType,如jdbcType=VARCHAR。确保正确处理null值可以避免此类报错。
摘要由CSDN通过智能技术生成

问题:使用MyBatis-plus+Orecle的一次查询引发的报错
完整错误

There was an unexpected error (type=Internal Server Error, status=500).
nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='cardId', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='cardId', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111

前提
这个是由于Orecle 数据库查询的时候参数是null (注意不是"",这个可以通过)
场景:
1:使用mybati-plus查询会出现报错
2:xml里也会报错

处理方法:
1:第一种情况直接加一个null的判断
2:第二种情况:在xml里加上对应的数据类型:如下,这里我的是字符串,加:jdbcType=VARCHAR

<select id="getInfoById" resultType="com.sinosoft.pojo.Infectioncard">
        select * from infectioncard where PATIENT_NAME=#{patientName,jdbcType=VARCHAR}
    </select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值