?? fooddaochaxun.java
字號:
package com.restrant.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import com.restrant.dao.ConnectionManager;
import com.restrant.entity.FoodBean;
public class FoodDaoChaxun implements FoodDao{
private Connection conn=null;
private PreparedStatement ps=null;
private ResultSet rs=null;
List<FoodBean> list=new ArrayList<FoodBean>();
public List<FoodBean> getFoods(){
String sql="SELECT foodID,foodName,remark ,foodPrice,description,foodImage FROM foodInfo";
try{
conn=ConnectionManager.getConnection();
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
FoodBean fb=new FoodBean();
fb.setFoodId(rs.getInt(1));
fb.setFoodName(rs.getString(2));
fb.setRemark(rs.getString(3));
fb.setFoodPrice(rs.getFloat(4));
fb.setDescription(rs.getString(5));
fb.setFoodImage(rs.getString(6));
list.add(fb);
}
}catch(Exception ex){
ex.printStackTrace();
}
return list;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -