java oop 第十二章宠物商店
DAO层
package cn.happy.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class BaseDao {
Connection con = null;
PreparedStatement ps = null;
public ResultSet rs=null;
private static final String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String url = "jdbc:sqlserver://localhost:1433;DatabaseName=PetShop";
private static final String username = "sa";
private static final String pwd = "1";
public Connection getCon()throws Exception{
Class.forName(driver);
if(con==null||con.isClosed()){
con = DriverManager.getConnection(url, username, pwd);
}
return con;
}
//执行查询
public ResultSet executeQuery(String sql,Object... obje) throws Exception{
con=getCon();
ps=con.prepareStatement(sql);
for(int i=0;i<obje.length;i++){
ps.setObject(i+1, obje[i]);
}
rs=ps.executeQuery();
return rs;
}
//测试修改
//执行修改
public int execteUpdate(String sql,Object...object) throws Exception{
con=getCon();
ps=con.prepareStatement(sql);
for(int i=0;i<object.length;i++){
ps.setObject(i+1, object[i]);
}
int count=ps.executeUpdate();
return count;
}
//单测增加
//执行增加
public int execteadd(String sql,Object...object) throws Exception{
con=getCon();
ps=con.prepareStatement(sql);
ps.executeUpdate();
for(int i=0;i<object.length;i++){
ps.setObject(i+1, object[i]);
}
int count=ps.executeUpdate();
return count;
}
//执行删除
//执行删除
public int exectedelete(String sql,Object...object) throws Exception{
con=getCon();
ps=con.prepareStatement(sql);
ps.executeUpdate();
for(int i=0;i<object.length;i++){
ps.setObject(i+1, object[i]);
}
int count=ps.executeUpdate();
return count;
}
public void closeAll() throws Exception{
if(rs!=null){
rs.close();
}
if(ps!=null){
ps.close();
}
if(con!=null){
con.close();
}
}
//
}
package cn.happy.dao;
import java.util.List;
import cn.happy.entity.Pet;
import cn.happy.entity.PetOwner;
public interface Petdao {
public List<Pet> select1() throws Exception;
public List<Pet> se1() throws Exception;
public boolean up(int id) throws Exception;
public List<Pet> poselect(int id) throws Exception;
public List<Pet> selectquan() throws Exception;
Pet getPetById(int id) throws Exception;
int buyPet(int petid,int ownerid) throws Exception;
int sellPet(int storeid,int petid) throws Exception;
public List<Pet> getOwnerPet(int ownerid) throws Exception ;
}
package cn.happy.dao;
import java.util.List;
import cn.happy.entity.Pet;
import cn.happy.entity.PetOwner;
public interface PetOwnerdao {
public List<PetOwner> select2() throws Exception;
public PetOwner DL(String name1) throws Exception;
public boolean update1(int money,int id) throws Exception;
public List<PetOwner> getnamebyid()throws Exception;
public int getIdByName(String name) throws Exception ;
public int updateByName(int money,String name) throws Exception ;
public int updateMoneyByName(int money, String name) throws Exception ;
}
package cn.happy.dao;
import java.util.List;
import cn.happy.entity.PetStore;
public interface PetStoredao {
public List<PetStore> select3() throws Exception;
public PetStore DL(String name1) throws Exception;
}
package cn.happy.dao;
public interface Accountdao {
public boolean add(int id)throws Exception;
int addAccount(int dealtype,int petid,int ownerid) throws Exception;
int addSellAccount(int dealtype,int petid,int ownerid,int storeid) throws Exception;
}
DAO Impl
package cn.happy.Impl;
import cn.happy.dao.Accountdao;
import cn.happy.dao.BaseDao;
public class AccountdaoImpl extends BaseDao implements Accountdao {
@Override
public boolean add(int id) throws Exception {
boolean flag=false;
String sql="insert into Account values(?,?,?)";
int count=this.execteU
相关知识
java oop 第十二章宠物商店
java宠物商店代码
mysql 项目案例宠物商店
java宠物商店项目
java宠物作业 java实训项目宠物商店
Java宠物商店源代码
mysql第十章宠物商店 宠物商店代码
Java宠物商店项目案例分析与实践
1218宠物商店简单设计说明书
宠物商店系统开发教程:Java课设源码解析
网址: java oop 第十二章宠物商店 https://www.mcbbbk.com/newsview808516.html
上一篇: 谁懂啊...这家宠物店的猫猫狗狗 |
下一篇: 圣宠宠物教您宠物店运营管理 |
推荐分享

- 1我的狗老公李淑敏33——如何 5096
- 2南京宠物粮食薄荷饼宠物食品包 4363
- 3家养水獭多少钱一只正常 3825
- 4豆柴犬为什么不建议养?可爱的 3668
- 5自制狗狗辅食:棉花面纱犬的美 3615
- 6狗交配为什么会锁住?从狗狗生 3601
- 7广州哪里卖宠物猫狗的选择性多 3535
- 8湖南隆飞尔动物药业有限公司宠 3477
- 9黄金蟒的价格 3396
- 10益和 MATCHWELL 狗 3352