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();
}
count(*)不能取出数据库中的内容。

解决方案 »

  1.   

    正如上面兄弟所说count(*)只能取得记录的数目,只能用来判断是否存在符合条件的记录!
      

  2.   

    count(*)取得的是满足条件的纪录的条数
    如果想取得记录,就要用
    select * from 表名 where 条件
    或者
    select 字段1,字段2... from 表名 where 条件
    建议你去学学sql语法
      

  3.   

    count(*)取得的是满足条件的纪录的条数
    如果想取得记录,就要用
    select * from 表名 where 条件
    或者
    select 字段1,字段2... from 表名 where 条件
    建议你去学学sql语法
      

  4.   

    楼上的几位有没有搞错。我是说我的getString("name")为何没有用。
    count(*)我知道那是记录数。就是因为它有用,所以我认为我的BEAN没有问题。那为何没有记录呢。
      

  5.   

    你是不是说,NAME字段的值显示的是“???”乱码啊?
      

  6.   

    你是不是要问:为什么NAME字段显示的是“????”啊?
      

  7.   

    to:dclfoxman(foxmandcl)ni
    呵呵,那位: zhaoweiemail(剑心) 的是对的,
    你用了select count(*) from ..
    就只能得到该查询的记录数,字段值是不能得到的,除非你用group by的用法,楼上的那位仁兄作的是对的,你试试,得闲去看看sql语法