我的这个简单的算法错在哪呀?再简单不过的代码了 我真笨
我想从数据库中查找书的类型号为1(即goodstype=1)的记录数,可结果为什么总是0呢???!!我写的代码如下:
public class GoodsBeanBo {
Connection ct=new ConnDb().getConn();
ResultSet rs=null;
Statement st=null;
public int getrowCount(int booktype){
int rowcount=0;
try {
st=ct.createStatemen(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=st.executeQuery("select count(*) from goods where goodstype="+booktype);
if(rs.next()){
rowcount=rs.getInt(1);
}
}catch (Exception e){
e.printStackTrace();
}finally{
this.close();
}
return rowcount;
}