数据库的数据类型明明是Integer ,而且也允许为空,为啥我修改为null报错呢

Scaarf 2017-05-01 12:31:17
数据库的数据类型明明是Integer ,而且也允许为空,为啥我修改为null报错呢
但是我在PL/SQL中修改为null都没问题,求问题出在哪。。。。。
这是contrlloer中的代码

Bicycle bicycle=new Bicycle();
bicycle.setBicycleId(Integer.parseInt(bicycleId));
bicycle.setCardCode(cardCode);
bicycle.setStatus(1);
bicycle.setPileId(null);
bicycle.setStationId(null);
bicycleServiceImpl.updateBicycleCardCode(bicycle);

这是sql语句

<update id="updateBicycleCardCode" parameterType="com.abc.bicycle.model.Bicycle">
update
bicycle
set
card_code=#{cardCode},
status=#{status},
station_id=#{stationId},
pile_id=#{pileId},
where
bicycle_id=#{bicycleId}
</update>

这是oracle数据库表



报错信息

org.springframework.jdbc.UncategorizedSQLException: 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: 无效的列类型

但是我在PL/SQL中修改为null都没问题,在PL/SQL中执行下面的SQL都没问题
update bicycle set status=1,pile_id=null,station_id=null where bicycle_id=39

求问题出在哪。。。。。

...全文
2484 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_41329728 2019-09-23
  • 打赏
  • 举报
回复
感谢博主和大家的解答
Scaarf 2017-05-01
  • 打赏
  • 举报
回复
引用 1 楼 zc881124 的回复:
网上帮忙查的 MyBatis 插入空值时,需要指定JdbcType。 附上链接http://blog.csdn.net/wangxmin2005/article/details/19753871 可以参考下。
确实是这个原因,谢谢,插入或者修改为null时要指定jdbcType 加上就好了
		<update id="updateBicycleCardCode" parameterType="com.abc.bicycle.model.Bicycle">
			update 
				bicycle 
			set 
				card_code=#{cardCode},
				status=#{status},
				station_id=#{stationId,jdbcType=INTEGER},
				pile_id=#{pileId,jdbcType=INTEGER}
			where 
				bicycle_id=#{bicycleId}
		</update>
110成成 2017-05-01
  • 打赏
  • 举报
回复
网上帮忙查的 MyBatis 插入空值时,需要指定JdbcType。 附上链接http://blog.csdn.net/wangxmin2005/article/details/19753871 可以参考下。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧