count(*)只统计记录个数,
"select name from guestbook";
这样才能取出name。

解决方案 »

  1.   

    你的sql语句明明是取记录总数,怎么能取字段呢,改成下面
    try
    {ResultSet countrs=null;
     countrs=showBean.executeQuery("select count(*) as cnt from guestbook");
    if(countrs.next())
    totalRec=countrs.getInt("cnt");
    countrs.close();
    countrs=showBean.executeQuery("select [name] from guestbook");
    if(countrs.next())
    out.print(countrs.getString("name"));
    countrs.close();
     showBean.closeStmt();
     }
    catch(Exception e){
    e.printStackTrace();
    }
      

  2.   

    你的sql语句明明是取记录总数,怎么能取字段呢,改成下面
    try
    {ResultSet countrs=null;
     countrs=showBean.executeQuery("select count(*) as cnt from guestbook");
    if(countrs.next())
    totalRec=countrs.getInt("cnt");
    countrs.close();
    countrs=showBean.executeQuery("select [name] from guestbook");
    if(countrs.next())
    out.print(countrs.getString("name"));
    countrs.close();
     showBean.closeStmt();
     }
    catch(Exception e){
    e.printStackTrace();
    }
      

  3.   

    你的sql语句明明是取记录总数,怎么能取字段呢,改成下面
    try
    {ResultSet countrs=null;
     countrs=showBean.executeQuery("select count(*) as cnt from guestbook");
    if(countrs.next())
    totalRec=countrs.getInt("cnt");
    countrs.close();
    countrs=showBean.executeQuery("select [name] from guestbook");
    if(countrs.next())
    out.print(countrs.getString("name"));
    countrs.close();
     showBean.closeStmt();
     }
    catch(Exception e){
    e.printStackTrace();
    }