是哪种数据库啊?@是什么意思?为什么PreparedStatement不行,哪里有错?

解决方案 »

  1.   

    StringBuffer().append组合成1个SQL语句,然后再执行这个SQL语句不就行啦
      

  2.   

    sql里有@吗?我孤陋寡闻了,把你现在的代码帖出来看下 啊
      

  3.   

    用PreparedStatment ps =conn.prePareStatment(select isnull(count(*),0)+1,?,? from B where B=?");
    ps.setString(1,"b");//注意ps.这里的数据类型与数据库表,和"b" 的类型想对应
    如:ps.setInt(2,3)
    如果用StringBuffer :
    StringBuffer sql=new StringBuffer();
    sql.append("select isnull(count(*),)) +1 , ");//注意空格
    sql.append(?);//你要的查询的
    sql.append(" , ");
    用的时候sql.toString() 就可以了
      

  4.   

    用String:
    String sql="insert into AAA(A,B,C)
    select isnull(count(*),0)+1,"+ 参数1+","+参数2+" from B where B='"+参数三+"'";用StringBuffer:
    StringBuffer sql = new StringBuffer();
    sql.append(="insert into AAA(A,B,C) select isnull(count(*),0)+1,").append(参数1)
    .append(",").append(参数2).append( " from B where B = ").append(参数3);
    或者(如果参数3即B的为字符串类型)
    StringBuffer sql = new StringBuffer();
    sql.append(="insert into AAA(A,B,C) select isnull(count(*),0)+1,").append(参数1)
    .append(",").append(参数2).append( " from B where B = '").append(参数3).append("'");
      

  5.   

    更正:
    sql.append("insert into AAA(A,B,C) ")没有"="号.
      

  6.   

    ECLIPSE提示isnull(count(*),0)+1不能识别 我晕倒了
      

  7.   

    count(*)会返回 null ? 没听过。
      

  8.   

    http://community.csdn.net/Expert/topic/5747/5747872.xml?temp=3.895205E-02