Data is Null. This method or property cannot be called on Null values.错误分析

在使用SqlClient的DataReader的时候,如果某一个字段值为NULL并且使用reader.getString方法获取的时候会出现“Data is Null. This method or property cannot be called on Null values.”异常。初步分析导致该异常的原因应该是:

  1、NULL值在DataReader中的类型是DBNULL。

  2、DBNULL和字符串的空白值String.Empty不是同样的概念。

  3、由于DBNULL和String.Empty不是同等值,因此SqlClient默认的实现没有对其进行强制转化而是直接抛出异常。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
java.sql.SQLIntegrityConstraintViolationException: Column 'buiID' cannot be null是一个数据库完整性约束错误。它表示在插入或更新数据时,buiID列的值不能为空。这意味着该列被定义为非空列,并且数据表的约束要求必须为每个记录提供一个非空值。 根据你提供的引用,错误可能是由于在postman中发送的请求参数中,buiID参数的值为空导致的。请确保在postman中正确设置了buiID参数的值,并且值不能为null。 此外,根据引用,还可能是由于数据库表定义了外键约束,并且外键关联的表中没有与buiID对应的记录。如果是这种情况,你需要确保buiID参数的值在关联表中有对应的记录。 因此,你需要检查postman中的参数设置和数据库表的定义,以确保buiID参数的值不为空,并且在关联表中有对应的记录。这样才能解决java.sql.SQLIntegrityConstraintViolationException: Column 'buiID' cannot be null的问题。<span class="em">1</span><span class="em">2</span> #### 引用[.reference_title] - *1* [报错 Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘xxxxxxxx‘ cannot be null](https://blog.csdn.net/weixin_45606985/article/details/129116193)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Caused by: java.sql.SQLIntegrityConstraintViolationException: Cannot delete or update a parent row:](https://download.csdn.net/download/weixin_38500572/13684759)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值