主键重复,对吗?读了又写,内容一致,十有八九是内容重复,与主键(索引等)设置有别你应该用updateString sql1 = "insert into message(sender,getter,subject,message,isread)values('"+sender+"','"+getter+"','"+subject+"','"+message+"','"+isread+"')";改为
String sql1 = "update message set isread='" + isread+ "' where you condition

解决方案 »

  1.   

    首先要明确你是要做INSERT 操作还是要做UPDATE 操作.如果只是想改一下isread 的值, 用上面的可以.
    String sql1 = "update message set isread=" + isread+ " where id="+postid+"";
      

  2.   

    还有 对于 INT 的操作要用:  "+ +"  , '"+ +"' 是用于STRING
      

  3.   

    主键应该不会重复吧,我是用sqlservel2000  让他自动增加的,列名为id,数据类型为int,把标识改为“是”。
      

  4.   

    我要的是INSERT 操作。
    我没有插入id,因为我已经叫他自动增加了。我的自动增加应该没有设错,其他地方都是这样用的。
      

  5.   

    TestBean.closeStmt();
    第二次调用之前调用一下这个...
    TestBean.execute(sql1);
    改成这个.
    我想到的两点,试试
      

  6.   

    请问:zez(鹤清风 为了老婆多挣钱 !) 
    是不是在
    TestBean.closeStmt();
    TestBean.closeConn();
    之间插入?
    出现的错误:
    An error occurred at line: 5 in the jsp file: /jsp/work/report.jsp
    Generated servlet error:
    D:\Tomcat\work\Standalone\localhost\examples\jsp\work\report_jsp.java:80: cannot resolve symbol
    symbol  : method execute (java.lang.String)
    location: class DataBase.MyDbBean
    TestBean.execute(sql1);
      

  7.   

    我把第二个
    TestBean.executeUpdate(sql1);
    改为TestBean.execute(sql1);后出现如下错误:An error occurred at line: 5 in the jsp file: /jsp/work/report.jsp
    Generated servlet error:
    D:\Tomcat\work\Standalone\localhost\examples\jsp\work\report_jsp.java:78: cannot resolve symbol
    symbol  : method execute (java.lang.String)
    location: class DataBase.MyDbBean
    TestBean.execute(sql1);
            ^
    6 errors
      

  8.   

    你最好把组成的sql语句在后台打出来看看
    然后放到数据库中运行一下
    估计就能看出错误