Db.update报空指针异常

chrishao 发布于 2014/05/06 23:15
阅读 1K+
收藏 0

【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”

Db.update("delete from users_extra_values where user_id = ?", userId);


在我执行这样一条语句的时候会报空指针异常,userId不为空


加载中
0
JFinal
JFinal

具体报的什么对象为空指针? 贴出异常信息,推测是你 ActiveRecordPlugin 数据源没有初始化成功

0
chrishao
chrishao

Caused by: java.lang.NullPointerException
    at com.jfinal.plugin.activerecord.Db.update(Db.java:290)
    at com.yiren.shiro.controller.UserController.uploadUserInfo(UserController.java:304)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
    at com.jfinal.plugin.activerecord.tx.Tx.intercept(Tx.java:76)

0
JFinal
JFinal

引用来自“chrishao”的评论

Caused by: java.lang.NullPointerException
    at com.jfinal.plugin.activerecord.Db.update(Db.java:290)
    at com.yiren.shiro.controller.UserController.uploadUserInfo(UserController.java:304)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
    at com.jfinal.plugin.activerecord.tx.Tx.intercept(Tx.java:76)

调试根踪一下 UserController.uploadUserInfo 下的 Db.update 这个方法,目测是数据库初始化不成功
0
番茄酱汁
番茄酱汁

链接对象为空吧?

0
超级大富
超级大富
该评论暂时无法显示,详情咨询 QQ 群:点此入群
0
JFinal
JFinal

再贴多些代码出来

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部