📄 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 + -