ssummeraw 2013-06-08 05:07 采纳率: 10%
浏览 3617

在 index 4 的 bind value 是 null

我使用的下面的代码,但是给出错误

String updateQuery ="INSERT INTO MAAccounts(userId, accountId, accountType, accountName, parentAccountId, currencyCode, isTransactionDefaultStatusOpen, currentBalance, monthlyBudget, createdOn, updatedOn) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 
        String[] valVars = { 
                stringToDB(account.userId),
                integerToDB(account.accountId).toString(),
                integerToDB(account.accountType.getValue()).toString(),
                stringToDB(account.accountName),
                (integerToDB(account.parentAccountId) != null ? integerToDB(account.parentAccountId).toString() : null),
                stringToDB(account.currencyCode),
                boolToDB(account.isTransactionDefaultStatusOpen).toString(),
                CurrencyToDB(account.currentBalance).toString(),
                CurrencyToDB(account.monthlyBudget).toString(),
                dateToDB(now),
                "false"};

        Cursor c = mDb.rawQuery(updateQuery, valVars);

错误:java.lang.IllegalArgumentException: the bind value at index 4 is null

请问如何解释这个错误?

  • 写回答

1条回答

  • 北边的世界 2013-06-08 10:51
    关注

    这个错误的意思是你sql语句中绑定的第四个值是空的。(integerToDB(account.parentAccountId) != null ? integerToDB(account.parentAccountId).toString() : null),
    这个判断语句中可能返回了一个null,因此报错。

    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?