jdbc action 接口示例
package com.gylhaut.action;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gylhaut.dao.GoddessDao;
import com.gylhaut.model.Goddess;
public class GoddessAction {
public void add(Goddess goddess) throws Exception{
GoddessDao dao= new GoddessDao();
dao.addGoddess(goddess);
}
public Goddess get(Integer id) throws Exception{
GoddessDao dao= new GoddessDao();
return dao.get(id);
}
public void edit(Goddess goddess) throws Exception{
GoddessDao dao= new GoddessDao();
dao.updateGoddess(goddess);
}
public void del(Integer id) throws Exception{
GoddessDao dao= new GoddessDao();
dao.delGoddess(id);
}
public List<Goddess> query() throws Exception{
GoddessDao dao= new GoddessDao();
return dao.query();
}
public List<Goddess> query(List<Map<String,Object>> params) throws Exception{
GoddessDao dao= new GoddessDao();
return dao.query(params);
}
/* public static void main(String[] args) throws Exception{
GoddessDao g= new GoddessDao();
//List<Goddess> gs = g.query("小妹");
List<Map<String,Object>> params = new ArrayList<Map<String,Object>>();
Map<String,Object> param = new HashMap<String,Object>();
param.put("name", "user_name");
param.put("rela","=");
param.put("value","'小妹'");
params.add(param);
List<Goddess> gs =g.query(params);
for(Goddess goddess : gs){
System.out.println(goddess.toString());
}*/
// Goddess g1= new Goddess();
// g1.setUser_name("小夏");
// g1.setAge(21);
// g1.setSex(1);
// g1.setBirthday(new Date());
// g1.setEmail("xiaoxia@163.com");
// g1.setMoblie("18500029090");
// g1.setUpdate_user("gylhaut");
// g1.setIsdel(1);
// //g1.setId(3);
// //g.delGoddess(3);
// //g.updateGoddess(g1);
// g.addGoddess(g1);
// Goddess gs1 = g.get(4);
// System.out.println(gs1.toString());
// }
}