[Microsoft]{ODBC驱动程序管理器]无效的游标状..怎么解决?
public class foodList {
public static List getFoodList(int page,int pageSize)
{
Connection conn=null;
PreparedStatement ps=null;
ResultSet rs=null;
List list=new ArrayList();
try {
foodBean foodbean;
conn=DBUtil.getConnection();
int row=(page-1)*pageSize;
String sql=null;
if(row==0){
sql="select top "+pageSize+" * from foodInfo";
}else{
sql="select top "+pageSize+" * from foodInfo where foodID not in (select top "+row+" foodID from foodInfo )";
}
ps=conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=ps.executeQuery();
while(rs.next())
{
foodbean =new foodBean();
foodbean.setFoodId(rs.getInt("foodID"));
foodbean.setFooName(rs.getString("foodName"));
foodbean.setRe(rs.getString("re"));
foodbean.setFoodPrice(rs.getDouble("foodPrice"));
foodbean.setDescription(rs.getString("description"));
foodbean.setFoodImage(rs.getString("foodImage"));
list.add(foodbean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
public class foodList {
public static List getFoodList(int page,int pageSize)
{
Connection conn=null;
PreparedStatement ps=null;
ResultSet rs=null;
List list=new ArrayList();
try {
foodBean foodbean;
conn=DBUtil.getConnection();
int row=(page-1)*pageSize;
String sql=null;
if(row==0){
sql="select top "+pageSize+" * from foodInfo";
}else{
sql="select top "+pageSize+" * from foodInfo where foodID not in (select top "+row+" foodID from foodInfo )";
}
ps=conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=ps.executeQuery();
while(rs.next())
{
foodbean =new foodBean();
foodbean.setFoodId(rs.getInt("foodID"));
foodbean.setFooName(rs.getString("foodName"));
foodbean.setRe(rs.getString("re"));
foodbean.setFoodPrice(rs.getDouble("foodPrice"));
foodbean.setDescription(rs.getString("description"));
foodbean.setFoodImage(rs.getString("foodImage"));
list.add(foodbean);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
foodbean.setFooName(rs.getString("foodName"));
foodbean.setRe(rs.getString("re"));
foodbean.setFoodPrice(rs.getDouble("foodPrice"));
foodbean.setDescription(rs.getString("description"));
foodbean.setFoodImage(rs.getString("foodImage"));
这里得顺序是否和数据库字段顺序一致