packageDao.Impl;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importjava.util.List;importentity.pet;importDB.JNDI;importDao.petDao;public class petDaoImpl extends JNDI implementspetDao {privateConnection cn;privatePreparedStatement ps;privateResultSet rs;public ListreturnList() {
List li=new ArrayList();
cn=super.getConnection();
String sql="select * from pet order by petId";try{
ps=cn.prepareStatement(sql);
rs=ps.executeQuery();while(rs.next()){
pet pe=newpet();
pe.setPetId(rs.getInt("petId"));
pe.setPetName(rs.getString("petName"));
pe.setPetBread(rs.getString("petBread"));
pe.setPetSex(rs.getString("petSex"));
pe.setBirthday(rs.getString("birthday"));
pe.setDescription(rs.getString("description"));
li.add(pe);
}
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}returnli;
}public intinsertPet(pet pet) {int i=0;
cn=super.getConnection();
String sql="insert into pet values (pet_squ.nextval,?,?,?,to_date(?,'YYYY-MM-dd'),?)";try{
ps=cn.prepareStatement(sql);
ps.setString(1,pet.getPetName() );
ps.setString(2, pet.getPetBread());
ps.setString(3,pet.getPetSex() );
ps.setString(4,pet.getBirthday() );
ps.setString(5,pet.getDescription() );
i=ps.executeUpdate();
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}returni;
}public ListselectPet(String petType) {
List li=new ArrayList();if(petType.equals("请选择")){
cn=super.getConnection();
String sql="select * from pet order by petId";try{
ps=cn.prepareStatement(sql);
rs=ps.executeQuery();while(rs.next()){
pet pe=newpet();
pe.setPetId(rs.getInt("petId"));
pe.setPetName(rs.getString("petName"));
pe.setPetBread(rs.getString("petBread"));
pe.setPetSex(rs.getString("petSex"));
pe.setBirthday(rs.getString("birthday"));
pe.setDescription(rs.getString("description"));
li.add(pe);
}
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}
}else{
cn=super.getConnection();
String sql="select * from pet where petBread=? order by petId";try{
ps=cn.prepareStatement(sql);
ps.setString(1,petType);
rs=ps.executeQuery();while(rs.next()){
pet pe=newpet();
pe.setPetId(rs.getInt("petId"));
pe.setPetName(rs.getString("petName"));
pe.setPetBread(rs.getString("petBread"));
pe.setPetSex(rs.getString("petSex"));
pe.setBirthday(rs.getString("birthday"));
pe.setDescription(rs.getString("description"));
li.add(pe);
}
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}
}returnli;
}
}
相关知识
探索宠物管理新纪元:基于JAVA的宠物管理系统
Java基于Java宠物寄存管理系统(源码+mysql+文档)
24基于java的宠物医院管理系统设计与实现基于java的宠物医院管理系统,基于ssm宠物管理系统,宠物系统,宠物管理,
Java基于Java宠物寄存管理系统(开题+源码)
基于Java Web的宠物管理系统
java毕业设计社区宠物管理与推荐系统
宠物店管理系统源码解析与Java实现
基于java的宠物领养管理系统
基于Java的宠物动物管理系统实现
基于java的宠物管理系统设计与实现
网址: java宠物管理系统 https://m.mcbbbk.com/newsview751757.html
上一篇: 蹭蹭app(宠物管理)下载 |
下一篇: 宠物商城后台管理系统(sprin |