?? allfoodsbean.java
字號:
package Entities;
import java.sql.*;
import java.util.*;
import javax.servlet.jsp.jstl.sql.Result;
import javax.servlet.jsp.jstl.sql.ResultSupport;
import Dao.*;
public class allFoodsBean {
private Connection con;
private String sql;
//返回FoodBean列表
public List getFoods()
{
List foods = new ArrayList();
//獲取書籍列表
try
{
SQLCommandBean sqlCommandBean = new SQLCommandBean();
con = ConnectionManage.getConnection();
sql = "select foodID,foodName,remark,foodPrice,description,foodImage from foodInfo";
sqlCommandBean.setConn(con);
sqlCommandBean.setSqlValue(sql);
Result result = sqlCommandBean.executeQuery();
if(result == null || result.getRowCount() == 0)
{
//沒有查出Book
System.out.print("沒有記錄");
}
else
{
int rowCount = result.getRowCount();
//讀取行數據
for(int i = 0; i < rowCount; i ++)
{
Map row = result.getRows()[i];
FoodBean food = new FoodBean();
food.setFoodID((String)row.get("foodID"));
food.setFoodName((String)row.get("foodName"));
food.setRemark((String)row.get("remark"));
food.setFoodPrice(Double.parseDouble(row.get("foodPrice").toString()));
//food.setFoodPrice(((Double) row.get("foodPrice")).doubleValue());
food.setDescription((String)row.get("description"));
food.setFoodImage((String)row.get("foodImage"));
foods.add(food);
}
}
}catch(Exception ex)
{
ex.printStackTrace();
}
return foods;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -