请帮助错误::: null指针异常 [英] please help error:::null pointer exception

查看:91
本文介绍了请帮助错误::: null指针异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码





if(ae.getSource()== bpaid)

{

int k;



rs = pst.executeQuery();

字符串状态= tfees.getText();

系统.out.println(status);



String ss =update fees set feesstatus =+ status +where fees.sid =+ roll +;

k = st.executeUpdate(ss);

if(k> 0)

{

System.out .println(记录已更新);

}





状态是已支付的费用状态/没有。

code


if (ae.getSource() == bpaid)
{
int k;

rs = pst.executeQuery();
String status = tfees.getText();
System.out.println(status);

String ss = "update fees set feesstatus= " + status + " where fees.sid=" + roll + "";
k = st.executeUpdate(ss);
if (k>0)
{
System.out.println("Record Is Updated");
}


status is the fees status paid / unpaid.

推荐答案

看起来你在这一行的末尾有一个额外的双引号字符。

Looks like you have an extra double quotation character at the end of this line.
String ss = "update fees set feesstatus= " + status + " where fees.sid=" + roll + ";



更改为


change to

String ss = "update fees set feesstatus= " + status + " where fees.sid=" + roll;





注意:在代码中使用空格并不是不好的做法,它使它更具可读性,更容易找到这种错误。

我重新格式化你的代码,并立即看到额外的字符。



Note: Using spaces in your code is not bad practice, it makes it more readable and it is easier to find this kind of errors.
I re-formatted your code and saw the extra character in an instant.


这篇关于请帮助错误::: null指针异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆