rs刚获得结果时,rs的指针指向结果集的上一行没有数据。 所以要想获得rs的值的正确方法为: while(rs.next()){ count= rs.getInt(1); } 而不是直接使用: count= rs.getInt(1);