正在学jsp和servlet,写了一段servlet,编译没问题,可访问jsp时出现错误
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
static public boolean checkQty(String wareID,int saleQty){
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try{
conn = ConnectionManager.getConnection();
stmt =conn.prepareStatement("select * from Reserve where wareID=" + wareID);
rs = stmt.executeQuery();
/*此处的rs出现问题*/
if(saleQty<=rs.getInt("ResQty")){
//System.err.println("售出量大于库存量");
System.out.println("saleQty<=resQty");
return true;
}
else{
System.err.println("售出量大于库存量");
return false;
}
//return true;
}
catch(java.sql.SQLException e){
System.out.println("SaleManager Info:");
System.err.println(e);
}
finally{
if(rs!=null){
try{
rs.close();
}
catch(Exception exception){}
}
if(stmt!=null){
try{
stmt.close();
}
catch(Exception exception){}
}
if(conn!=null){
try{
conn.close();
}
catch(Exception exception){}
}
}
return false;
//System.out.println("售出量大于库存量");
}