当前位置: 技术问答>java相关
怎么在写入数据库的时候会出现这样的问题?
来源: 互联网 发布时间:2015-05-22
本文导语: 我是新手,很多地方很不明白,常犯低级的错误,请大家指教!谢谢! 源代码: Untitled 你的定单号为:,请随时查询定单!谢谢您的购买,再见! 错误信息: Full compiler error(s): F:MyWebWEB-INF_tmp_war_myserver_myse...
我是新手,很多地方很不明白,常犯低级的错误,请大家指教!谢谢!
源代码:
Untitled
你的定单号为:,请随时查询定单!谢谢您的购买,再见!
错误信息:
Full compiler error(s):
F:MyWebWEB-INF_tmp_war_myserver_myserver_MyWebjsp_servlet_project1_custom__save.java:124: variable customorderid might not have been initialized
SQL="insert into customorder(customorderid,customid,totalmoney,orderdate,productid,quantity)VALUES('"+customorderid+"','"+user+"','"+totalmoney+"','"+orderdate+"','"+productid+"','"+quantity+"',)"; //[ /project1/custom/save.jsp; Line: 35]
^
F:MyWebWEB-INF_tmp_war_myserver_myserver_MyWebjsp_servlet_project1_custom__save.java:124: variable totalmoney might not have been initialized
SQL="insert into customorder(customorderid,customid,totalmoney,orderdate,productid,quantity)VALUES('"+customorderid+"','"+user+"','"+totalmoney+"','"+orderdate+"','"+productid+"','"+quantity+"',)"; //[ /project1/custom/save.jsp; Line: 35]
^
Note: F:MyWebWEB-INF_tmp_war_myserver_myserver_MyWebjsp_servlet_project1_custom__save.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
2 errors
为什么说我的costomorderid,totalmoney可能没有被初始化阿?很不明白。谢谢!
源代码:
Untitled
你的定单号为:,请随时查询定单!谢谢您的购买,再见!
错误信息:
Full compiler error(s):
F:MyWebWEB-INF_tmp_war_myserver_myserver_MyWebjsp_servlet_project1_custom__save.java:124: variable customorderid might not have been initialized
SQL="insert into customorder(customorderid,customid,totalmoney,orderdate,productid,quantity)VALUES('"+customorderid+"','"+user+"','"+totalmoney+"','"+orderdate+"','"+productid+"','"+quantity+"',)"; //[ /project1/custom/save.jsp; Line: 35]
^
F:MyWebWEB-INF_tmp_war_myserver_myserver_MyWebjsp_servlet_project1_custom__save.java:124: variable totalmoney might not have been initialized
SQL="insert into customorder(customorderid,customid,totalmoney,orderdate,productid,quantity)VALUES('"+customorderid+"','"+user+"','"+totalmoney+"','"+orderdate+"','"+productid+"','"+quantity+"',)"; //[ /project1/custom/save.jsp; Line: 35]
^
Note: F:MyWebWEB-INF_tmp_war_myserver_myserver_MyWebjsp_servlet_project1_custom__save.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
2 errors
为什么说我的costomorderid,totalmoney可能没有被初始化阿?很不明白。谢谢!
|
可以呀
if(rs2.next()){
float totalmoney1=(float)((float)rs2.getInt("price")*(new Integer("quantity")).intValue());
totalmoney=totalmoney+totalmoney1;
}else totalmoney=0;
这下子可以了吧,呵呵
if(rs2.next()){
float totalmoney1=(float)((float)rs2.getInt("price")*(new Integer("quantity")).intValue());
totalmoney=totalmoney+totalmoney1;
}else totalmoney=0;
这下子可以了吧,呵呵
|
变量定义时直接复值为NULL,这样就初始化了,试试