第二次执行的结果应该有一条记录,但是if(rs.next()){System.out.ptintln("???????????");....}打印语句都没有打

解决方案 »

  1.   

    ResultSet你有给属性吗?比如说可滚动的,敏感的?
      

  2.   

    我刚才改了一下程序,分别声明了两个statement和resultset,结果还是不行,和不改之前是一样的,不知道怎么搞的
      

  3.   

    下面是代码,大家帮忙看看:
    public List[] doAreaSearch(String[] Area, String[] Product) {
    List[] areaList = new ArrayList[Area.length];
    conn=new ConnectionDB().connectionDB();
    for (int i = 0; i < Area.length; i++) {
    try {
    stmt1 = conn.createStatement();
    } catch (SQLException e1) {
    e1.printStackTrace();
    }
    StringBuffer sbuffer = new StringBuffer();
    sbuffer.append("select shi as shi,");
    for (int j = 0; j < Product.length; j++) {
    sbuffer
    .append("sum(" + Product[j] + ") as " + Product[j]
    + " ");
    if (j + 1 != Product.length) {
    sbuffer.append(",");
    }
    }
    sbuffer.append("from PCJD_QYXX where shi='" + Area[i]
    + "' group by shi");
    System.out.println(sbuffer.toString());
    try {
    rs1 = stmt1.executeQuery(sbuffer.toString());
    } catch (SQLException e) {
    e.printStackTrace();
    }
    try {
    if (rs1.next()) {
    System.out.println("rrrrrrr");
    areaList[i].add(rs1.getString("shi"));
    System.out.println("shi:" + rs1.getString("shi"));
    for (int k = 0; k < Product.length; k++) {
    areaList[i].add(rs1.getString(Product[k]));
    }
    System.out.println("areaList[i] size" + areaList.length);
    }
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    try {
    rs1.close();
    stmt1.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }
    return areaList;
    }
      

  4.   

    catch   (SQLException   e)改成catch   (Exception   e)然后等着看 异常错误信息吧!贴上来
      

  5.   

    当生成 ResultSet 对象的 Statement 对象关闭、重新执行或用来从多个结果的序列检索下一个结果时,ResultSet 对象会自动关闭。