public int allCity() {
 StringBuffer strQuery=new StringBuffer();
     strQuery.append("select count(*)  from QQC_LABOURER");
try {
printQuery(strQuery);
return getCount(strQuery.toString());
    System.out.print(strQuery.toString());
} catch (DbConnPoolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
这个getCount方法应该怎么写

解决方案 »

  1.   

    连接数据库
    执行你的sql语句
    得到result对像
      

  2.   

    执行查询返回list.用return Integer.parseInt(list.get(0).toString())
      

  3.   

    然后 return rs.getInt(1);//rs为ResultSet对象
      

  4.   

    连接数据库 
    执行你的sql语句 
    得到result对像 
     
    然后 
    Java codereturn rs.getInt(1);//rs为ResultSet对象