易截截图软件、单文件、免安装、纯绿色、仅160KB

请教一个jsp简单的mysql问题

是一条更新操作:
Java code:

……
private Integer bonus = 0;
public Integer getBonus() {
return bonus;
}
public void setBonus(Integer bonus) {
this.bonus = bonus;
}


String SQL = "UPDATE users SET bonus = bonus" + this.getBonus()
+ " WHERE id='" + this.getID() + "'";
new DataBase().executeUpdate(SQL);



原意是把数据库中原有的bonus值取出后加上新的this.getBonus()后再放回到bonus字段中。

可是发现这条sql语句执行之后是错误的:
SQL code:

SET bonus=bonus3 WHERE id='2' 附近有误



真晕!,原来是bonus和this.getBonus()没有进行加法运算,而是字符连接运算了!

怎么改?????????
顶下,没看明白。

如果你的数据库是MYSQL的话
String SQL = "UPDATE users SET bonus = concat(this.getBonus(),bonus)" +
                + " WHERE id='" + this.getID() + "'";
        new DataBase().executeUpdate(SQL);




如果上面的不行你再试试下面的
String SQL = "UPDATE users SET bonus = bonus||”+this.getBonus
              &


相关问答:

关于jsp论坛 - Java / Web 开发

我现在想用ssh整合来做一个论坛,但数据库方面不行,我主要不会涉及数据库,不知道发帖表,和回帖表要如何设计和区分。不知道谁有一个简单的思路,来设计这些表。谢谢了。
发帖和回帖用同一张表 。发帖 id user ......

JSP中的中文字符处理

<%@ page contentType = "text/html;charset =gb2312"%>

<%!
    public String codeToString(String str)
  {
    String s =str;
  &nbs ......

求助jsp中运行Javabean问题

SetGetPropertytest.jsp源代码如下,谢谢大家前来帮忙,同时祝大家中秋快乐
<%@ page c%>
<HTML>
<HEAD>
<TITLE>setProperty动作与getProperty动作范例 </TITLE> ......

jsp调用JavaBean tomcat出项问题

package tom.jiafei;

public class Student {
String name=null;
long number;
double weight,height;
public String getName() {
return name;
}
public void setName(Strin ......

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号