首页 > 分享 > java宠物商店 jdbc宠物商店

java宠物商店 jdbc宠物商店

用jdbc实现宠物商店管理系统
1,开发语言:java(JDK8)
2,开发工具:IntelliJ IDEA 2021.2.3
3,数据库:MySQL
4,操作系统:Windows10
5,需要引入的jar包:mysql-connector-java-8.0.26.jar,下载地址:https://mvnrepository.com/artifact/mysql/mysql-connector-java/8.0.26

package com.impl; import com.dao.BaseDAO; import java.sql.Connection; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.InputMismatchException; import java.util.Scanner; /** * @author 咕噜科 * ClassName: PetManage * date: 2021/8/26 22:12 * Description: * version 1.0 */ public class PetManage extends BaseDAO { /** * */ public void showAll() { showPetName(); showPetOwner(); showPetStore(); login(); } /** * 显示宠物的姓名以及ID方法 */ public void showPetName() { conn = getConnection(); String sql = "SELECT id,pet_name from pet"; try { state = conn.prepareStatement(sql); rs = state.executeQuery(); System.out.println("Wonderland醒来,所有宠物从MySQL中醒来"); System.out.println("*************************************"); int num = 1; while (rs.next()) { int id = rs.getInt("id"); String name = rs.getString("pet_name"); System.out.println("第" + num + "只宠物,名字叫:" + name); num++; } System.out.println("*************************************n"); } catch (Exception e) { e.printStackTrace(); } finally { closeObject1(); } } /** * 显示宠物主人方法 */ public void showPetOwner() { conn = getConnection(); String sql = "select id,owner_id,owner_name,money from pet_owner where owner_type = 1"; try { state = conn.prepareStatement(sql); rs = state.executeQuery(); System.out.println("所有宠物主人从MySQL中醒来"); System.out.println("*************************************"); int num = 1; while (rs.next()) { String name = rs.getString("owner_name"); System.out.println("第" + num + "主人的名字叫:" + name); num++; } System.out.println("*************************************n"); } catch (Exception e) { e.printStackTrace(); } finally { closeObject1(); } } /** * 显示宠物商店方法 */ public void showPetStore() { conn = getConnection(); String sql = "select id,owner_id,owner_name,money,address from pet_owner where owner_type = 2"; try { state = conn.prepareStatement(sql); rs = state.executeQuery(); System.out.println("所有宠物商店从MySQL中醒来"); System.out.println("*************************************"); int num = 1; while (rs.next()) { String storeName = rs.getString("owner_name"); String storeAddress = rs.getString("address"); System.out.println("第" + num + "个商店的名字叫: " + storeName + " ,地址在: " + storeAddress); num++; } System.out.println("*************************************n"); } catch (Exception e) { e.printStackTrace(); } finally { closeObject1(); } } /** * 登录界面选择是主人登录还是商店登录方法 */ public void login() { System.out.println("请选择输入登录模式n1.宠物主人登录n2.宠物商店登录n3.退出系统n-------------------"); try { Scanner input = new Scanner(System.in); int choise = input.nextInt(); if (choise < 1 || choise > 3) { System.out.println("输入有误,请重新选择"); login(); } else { switch (choise) { case 1: petOwnerLogin(); break; case 2: petStoreLogin(); break; case 3: System.out.println("谢谢使用"); System.exit(0); break; default: break; } } } catch (InputMismatchException e) { System.out.println("输入有误,请重新选择"); login(); } } /** * 宠物主人登录方法 * * @return */ public boolean petOwnerLogin() { boolean flag = false; try { Scanner input = new Scanner(System.in); System.out.println("请先登录,请您先输入主人的名字"); String name = input.next(); System.out.println("请您输入主人的密码:"); String password = input.next(); conn = getConnection(); String sql = "SELECT owner_name,password from pet_owner where owner_name=? and password=?"; try { state = conn.prepareStatement(sql); state.setString(1, name); state.setString(2, password); rs = state.executeQuery(); if (rs.next()) { System.out.println("---------恭喜您成功登录!---------"); System.out.println("----------您的基本信息---------"); conn = getConnection(); String sql2 = "SELECT id,owner_name,owner_id,password,money from pet_owner where owner_name=?"; //state=conn.prepareStatement(sql2); //state.setString(1, name); //rs=state.executeQuery(); rs = search(sql2, name); if (rs.next()) { int uid = rs.getInt("owner_id"); String uname = rs.getString("owner_name"); Double uMoney = rs.getDouble("money"); System.out.println("登录成功!!!!"); System.out.println("姓名:" + uname); System.out.println("元宝数:" + uMoney); dealPet(uname, uid); } } else { System.out.println("登录失败,账户与密码不匹配"); login(); } } catch (Exception e) { e.printStackTrace(); } } catch (InputMismatchException e) { System.out.println("输入有误"); login(); } return false; } /** * 选择买宠物或者卖宠物的方法 */ public void dealPet(String ownerName, int uid) { System.out.println("您可以购买和卖出宠物,购买宠物请输入1,卖出宠物请输入2n1.购买宠物n2.卖出宠物n3.返回上一级n4.退出系统"); try { Scanner input2 = new Scanner(System.in); int choise2 = input2.nextInt(); if (choise2 < 1 || choise2 > 4) { System.out.println("输入有误"); dealPet(ownerName, uid); } else { switch (choise2) { case 1: //购买宠物 buyPet(ownerName, uid); break; case 2: //出售宠物 showSellPet(ownerName, uid); break; case 3: //返回上一级 login(); break; case 4: System.out.println("--------谢谢使用------"); System.exit(0); default: break; } } } catch (InputMismatchException e) { System.out.println("输入有误"); dealPet(ownerName, uid); } } /** * 显示主人拥有的宠物 */ public void showSellPet(String ownerName, int uid) { conn = getConnection(); String sql25 = "select id,pet_name,pet_price,pet_role_type,pet_type from pet where owner_type = 1 and owner_id =" + uid; try { state = conn.prepareStatement(sql25); rs = state.executeQuery(); System.out.println("以下是你拥有的宠物:"); ////如果结果集为空,即该主人没有宠物,就返回上一级进行选择 //if(!rs.next()){ //System.out.println("您没有宠物,将自动返回上一级"); //buyPet(ownerName, uid); //} int num = 1; while (rs.next()) { int petid = rs.getInt("id"); String petName = rs.getString("pet_name"); String petPrice = rs.getString("pet_price"); System.out.println("这是" + num + "只宠物,编号是" + petid + ",名字叫:" + petName + ",需要" + petPrice + "个元宝"); num++; } System.out.println("**************************************"); } catch (SQLException e) { e.printStackTrace(); } closeObject1(); sellPet(ownerName, uid); } public void sellPet(String ownerName, int uid) { System.out.println("请输入你想卖出的宠物编号:"); try { Scanner input27 = new Scanner(System.in); int choisePetId = input27.nextInt(); //先查询下有哪些商店 String queryStore = "select owner_id,owner_name from pet_owner where owner_type = 2"; Connection queryStoreConn = getConnection(); try { state = queryStoreConn.prepareStatement(queryStore); rs = state.executeQuery(); int num = 1; if (rs.next()) { //说明有商店存在 System.out.println("请输入你要卖给的商店编号"); int storeId1 = rs.getInt("owner_id"); String storeName = rs.getString("owner_name"); System.out.println(num + "." + storeName+"编号t:"+storeId1); num++; while (rs.next()) { int storeId = rs.getInt("owner_id"); String storeName2 = rs.getString("owner_name"); System.out.println(num + "." + storeName2+"t编号:"+storeId); num++; } System.out.println("8888.返回上一级n9999.退出系统"); int storeId = input27.nextInt(); if (storeId == 8888) { dealPet(ownerName, uid); } else if (storeId == 9999) { System.out.println("-------谢谢使用-------"); System.exit(0); } String sql30 = "select pet_name,pet_price,pet_role_type,pet_type from pet where owner_type = 1 and owner_id = "+uid+" and id = "+choisePetId; Connection conn6 = getConnection(); try { state = conn6.prepareStatement(sql30); rs = state.executeQuery(); if (rs.next()) { String petPrice = rs.getString("pet_price");//宠物价格 Connection conn9 = getConnection(); conn9.setAutoCommit(false); //修改宠物信息 String sql40 = "update pet set owner_type= 2,owner_id=" + storeId + " where id=" + choisePetId; state = conn9.prepareStatement(sql40); int result20 = state.executeUpdate(); //卖主加钱 String sql41 = "update pet_owner set money = money +" + petPrice + " where owner_type = 1 and owner_id =" +uid; state = conn9.prepareStatement(sql41); int result21 = state.executeUpdate(); //商店扣钱 String sql42 = "update pet_owner set money = money -" + petPrice + " where owner_type = 2 and owner_id =" + storeId; state = conn9.prepareStatement(sql42); int result22 = state.executeUpdate(); //获得当前时间 Long time1 = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String dealTime = sdf.format(time1); //将该条交易添加至交易账单中 String sql43 = "insert into account_info (account_type,pet_id,sale_owner_id,buy_owner_id,price,create_time) VALUES (2," + choisePetId + "," + storeId + "," + uid + "," + petPrice + ",'" + dealTime + "')"; state = conn9.prepareStatement(sql43); int result23 = state.executeUpdate(); if (result20 > 0 && result21 > 0 && result22 > 0 & result23 > 0) { //提交事务 conn9.commit(); System.out.println("卖出成功"); } else { //回滚事务 System.out.println("出售失败"); conn9.rollback(); } dealPet(ownerName, uid); } else { System.out.println("没有该宠物,卖出失败"); dealPet(ownerName, uid); } } catch (SQLException e) { e.printStackTrace(); System.out.println("系统异常"); dealPet(ownerName, uid); } } else { //没有商店,返回到上一级 dealPet(ownerName, uid); } } catch (SQLException e) { e.printStackTrace(); System.out.println("数据库查询异常!!!"); dealPet(ownerName, uid); } } catch (InputMismatchException e) { System.out.println("输入错误,请重新输入"); sellPet(ownerName, uid); } } ///** // * 显示新培育宠物并且购买 // */ //public void showNewPet() { //// TODO Auto-generated method stub // //} /** * 宠物商店登录的方法 * * @return */ public boolean petStoreLogin() { boolean flag = false; try { Scanner input = new Scanner(System.in); System.out.println("请先登录,请您先输入宠物商店的名字"); String name = input.next(); System.out.println("请您输入宠物商店的密码:"); String password = input.next(); conn = getConnection(); String sq110 = "select owner_id,owner_name,money from pet_owner where owner_type = 2 and owner_name=? and password=?"; state = conn.prepareStatement(sq110); rs = search(sq110, name, password); if (rs.next()) { String storeId = rs.getString("owner_id"); System.out.println("登录成功"); PetStoreMake(name,storeId); } else { System.out.println("登录失败"); login(); } } catch (Exception e) { // TODO: handle exception } return false; } /* * 宠物商店培育新宠物 */ public void PetStoreMake(String storeName,String storeId) throws SQLException { System.out.println("请输入数字进行选择:n1.查询店内宠物n2.培育新宠物n3.退出登录n4.退出系统"); try { Scanner input = new Scanner(System.in); int choise7 = input.nextInt(); if (choise7 < 1 || choise7 > 3) { System.out.println("输入有误"); PetStoreMake(storeName,storeId); } else { switch (choise7) { case 1: storePetQuery(storeName,storeId); break; case 2: storeAddPet(storeName,storeId); break; case 3: //退出登录,返回上一级 login(); break; case 4: System.out.println("-------谢谢使用-------"); System.exit(0); default: break; } } } catch (InputMismatchException e) { System.out.println("输入有误"); PetStoreMake(storeName,storeId); } } /** * 宠物商店培育新宠物的方法 * * @param storeName * @throws SQLException */ public void storeAddPet(String storeName,String storeId) throws SQLException { System.out.println("请输入你想添加的宠物的品种名称(例如:金渐层):"); Scanner input = new Scanner(System.in); String typename = input.next(); System.out.println("请输入该宠物的名字:"); String petName = input.next(); System.out.println("请输入该宠物的类型:n1.普通宠物n2.新型宠物"); int animalType = input.nextInt(); System.out.println("请输入该宠物的价格:"); int price = input.nextInt(); try { Connection conn9 = getConnection(); String sql13 = "insert into pet(pet_name,owner_id,owner_type,pet_price,pet_role_type,pet_type) values ('"+petName+"',"+storeId+",2,"+price+",'"+animalType+"','"+typename+"')"; state = conn9.prepareStatement(sql13); int a = state.executeUpdate(); if (a > 0) { System.out.println("培育新宠物成功"); PetStoreMake(storeName,storeId); } else { System.out.println("培育新宠物失败"); PetStoreMake(storeName,storeId); } }catch (Exception e){ e.printStackTrace(); } } /** * 在商店登录之后进行对店内的宠物进行查询 * * @param storeName */ public void storePetQuery(String storeName,String storeId) { System.out.println("正在查询店内宠物。。。"); conn = getConnection(); String sql11 = "select id,pet_name,pet_price,pet_role_type,pet_type from pet where owner_type = 2 and owner_id = " + storeId; try { state = conn.prepareStatement(sql11); rs = state.executeQuery(); int i = 1; while (rs.next()) { int id = rs.getInt("id"); String name = rs.getString("pet_name"); String typename = rs.getString("pet_type"); String petPrice = rs.getString("pet_price"); System.out.println("第" + i + "只宠物编号是:"+id+",名字:" + name + ",宠物类型:" + typename + ",价格:" + petPrice); i++; } System.out.println("----------------------------"); PetStoreMake(storeName,storeId); } catch (Exception e) { e.printStackTrace(); } } /** * 购买宠物的方法 */ public void buyPet(String ownerName, int uid) { System.out.println("请输入选择购买范围,只输入选择项的序号"); System.out.println("1:购买库存宠物n2.购买新培育宠物n3.返回上一级"); try { Scanner input3 = new Scanner(System.in); int choise5 = input3.nextInt(); if (choise5 < 1 || choise5 > 3) { System.out.println("输入有误"); buyPet(ownerName, uid); } else { switch (choise5) { case 1: showPetAll(ownerName, uid, 2); break; case 2: buyNewPet(ownerName, uid, 2); break; case 3: //返回上一级 dealPet(ownerName, uid); break; default: break; } } } catch (InputMismatchException e) { System.out.println("输入有误"); buyPet(ownerName, uid); } } public void buyNewPet(String ownerName, int uid, int petRoleType) { //用于判断查询是否有结果 boolean havePet = false; System.out.println("正在帮你查询新宠物。。。。。"); conn = getConnection(); String sql31 = "SELECT id,pet_name,pet_price from pet where pet_role_type= 2 and owner_type = 2"; try { state = conn.prepareStatement(sql31); rs = state.executeQuery(); while (rs.next()) { int petid = rs.getInt("id"); String petName = rs.getString("pet_name"); String petPrice = rs.getString("pet_price"); System.out.println("序号为:" + petid + ",名字为:" + petName + ",需要" + petPrice + "个元宝"); havePet = true; } if (havePet) { System.out.println("请输入你要购买的新宠物的序号:"); try { //boolean havePet2=false; Scanner input28 = new Scanner(System.in); int newPetId = input28.nextInt(); Connection conn7 = getConnection(); String sql32 = "SELECT id,pet_name,pet_price,pet_role_type,owner_id from pet where owner_type = 2 and id = " + newPetId; state = conn7.prepareStatement(sql32); rs = state.executeQuery(); if (rs.next()) { int storeid = rs.getInt("owner_id"); int petPrice = rs.getInt("pet_price"); Connection conn8 = getConnection(); conn8.setAutoCommit(false); //修改宠物所属信息 String sql33 = "update pet set owner_type= 1,owner_id=" + uid + " where id=" + newPetId; //修改买主账户金额 String sql34 = "update pet_owner set money=money-" + petPrice + " where owner_type = 1 and owner_id =" + uid; //修改商店金额 String sql35 = "update pet_owner set money=money+" + petPrice + " where owner_type = 2 and owner_id =" + storeid; //获得当前时间 Long time1 = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String dealTime = sdf.format(time1); //将该条交易添加至交易账单中 String sql36 = "insert into account_info (account_type,pet_id,sale_owner_id,buy_owner_id,price,create_time) VALUES (2," + newPetId + "," + storeid + "," + uid + "," + petPrice + ",'" + dealTime + "')"; state = conn8.prepareStatement(sql33); int result13 = state.executeUpdate(); state = conn8.prepareStatement(sql34); int result14 = state.executeUpdate(); state = conn8.prepareStatement(sql35); int result15 = state.executeUpdate(); state = conn8.prepareStatement(sql36); int result16 = state.executeUpdate(); if (result13 > 0 && result14 > 0 && result15 > 0 && result16 > 0) { //如果都成功执行,改变数据,那就提交事务 conn8.commit(); System.out.println("购买成功"); } else { //如果中加你有一条没有执行成功那就回滚事务 System.out.println("购买失败"); conn8.rollback(); } buyPet(ownerName, uid); } else { System.out.println("输入错误,没有该序号的新宠物"); buyNewPet(ownerName, uid, 2); } } catch (InputMismatchException e) { e.printStackTrace(); } } else { System.out.println("暂时还没新宠物"); buyPet(ownerName, uid); } } catch (SQLException e) { e.printStackTrace(); } } /** * 展示库存宠物名字,序号,类型的方法 */ public void showPetAll(String ownerName, int uid, int petRoleType) { System.out.println("---------以下是库存宠物--------"); conn = getConnection(); String sql6 = "SELECT pet.id,pet_name,pet_type,pet_role_type,pet_price,pet.owner_id,pet.owner_type,owner_name from pet,pet_owner where pet.owner_id = pet_owner.owner_id and pet_role_type = 1 and pet.owner_type = 2"; try { state = conn.prepareStatement(sql6); rs = state.executeQuery(); while (rs.next()) { int petId = rs.getInt("pet.id"); int owner_id = rs.getInt("pet.owner_id"); String petName = rs.getString("pet_name"); String storeName = rs.getString("owner_name"); String petType = rs.getString("pet_type"); String money = rs.getString("pet_price"); System.out.println("序号:" + petId + ",我的名字叫:" + petName + ",我的品种是:" + petType + ",要购买我要花:" + money + "个元宝!我属于:" + storeName); } System.out.println("请输入你想购买的宠物编号:"); try { Scanner input17 = new Scanner(System.in); int choise6 = input17.nextInt(); //对在商店里的宠物进行ID查询,符合的就购买 conn = getConnection(); String sql15 = "select id,pet_name,pet_price,pet_role_type,pet_type,owner_id from pet where id =" + choise6; try { state = conn.prepareStatement(sql15); rs = state.executeQuery(); if (rs.next()) { //这里是宠物主人购买宠物的代码,将宠物的store_ID设置为null,将宠物的owner_ID设置为购买主人的ID //然后主人账户减钱,商店的结余加钱,将该条交易添加至交易账单中 int store_id = rs.getInt("owner_id");//这里是选择的宠物所属商店的ID int petPrice = rs.getInt("pet_price");//宠物价格 //这里用创建一个新的连接 Connection conn1 = getConnection(); //开启事务 conn1.setAutoCommit(false); //将宠物的主人类型改为个人- 1,将宠物的主人id设置为购买主人的ID String sql18 = "update pet set owner_type=1,owner_id=" + uid + " where pet.id=" + choise6; //宠物主人减钱 String sql19 = "update pet_owner set money = money -" + petPrice + " where owner_type = 1 and owner_id=" + uid; //宠物商店加钱 String sql20 = "update pet_owner set money = money +" + petPrice + " where owner_type = 2 and owner_id=" + store_id; //获得当前时间 Long time1 = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dealTime = sdf.format(time1); //将该条交易添加至交易账单中 String sql21 = "insert into account_info (account_type,pet_id,sale_owner_id,buy_owner_id,price,create_time) VALUES (1," + choise6 + "," + store_id + "," + uid + "," + petPrice + ",'" + dealTime + "')"; state = conn1.prepareStatement(sql18); int result2 = state.executeUpdate(); state = conn1.prepareStatement(sql19); int result3 = state.executeUpdate(); state = conn1.prepareStatement(sql20); int result4 = state.executeUpdate(); state = conn1.prepareStatement(sql21); int result5 = state.executeUpdate(); if (result2 > 0 && result3 > 0 && result4 > 0 && result5 > 0) { //如果都成功执行,改变数据,那就提交事务 conn1.commit(); System.out.println("购买成功"); } else { //如果中加你有一条没有执行成功那就回滚事务 System.out.println("购买失败"); conn1.rollback(); } //返回上一级 buyPet(ownerName, uid); } else { System.out.println("购买失败"); //返回上一级 buyPet(ownerName, uid); } } catch (SQLException e) { e.printStackTrace(); } } catch (InputMismatchException e) { System.out.println("输入有误"); showPetAll(ownerName, uid, 1); } } catch (SQLException e) { e.printStackTrace(); } } }1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.267.268.269.270.271.272.273.274.275.276.277.278.279.280.281.282.283.284.285.286.287.288.289.290.291.292.293.294.295.296.297.298.299.300.301.302.303.304.305.306.307.308.309.310.311.312.313.314.315.316.317.318.319.320.321.322.323.324.325.326.327.328.329.330.331.332.333.334.335.336.337.338.339.340.341.342.343.344.345.346.347.348.349.350.351.352.353.354.355.356.357.358.359.360.361.362.363.364.365.366.367.368.369.370.371.372.373.374.375.376.377.378.379.380.381.382.383.384.385.386.387.388.389.390.391.392.393.394.395.396.397.398.399.400.401.402.403.404.405.406.407.408.409.410.411.412.413.414.415.416.417.418.419.420.421.422.423.424.425.426.427.428.429.430.431.432.433.434.435.436.437.438.439.440.441.442.443.444.445.446.447.448.449.450.451.452.453.454.455.456.457.458.459.460.461.462.463.464.465.466.467.468.469.470.471.472.473.474.475.476.477.478.479.480.481.482.483.484.485.486.487.488.489.490.491.492.493.494.495.496.497.498.499.500.501.502.503.504.505.506.507.508.509.510.511.512.513.514.515.516.517.518.519.520.521.522.523.524.525.526.527.528.529.530.531.532.533.534.535.536.537.538.539.540.541.542.543.544.545.546.547.548.549.550.551.552.553.554.555.556.557.558.559.560.561.562.563.564.565.566.567.568.569.570.571.572.573.574.575.576.577.578.579.580.581.582.583.584.585.586.587.588.589.590.591.592.593.594.595.596.597.598.599.600.601.602.603.604.605.606.607.608.609.610.611.612.613.614.615.616.617.618.619.620.621.622.623.624.625.626.627.628.629.630.631.632.633.634.635.636.637.638.639.640.641.642.643.644.645.646.647.648.649.650.651.652.653.654.655.656.657.658.659.660.661.662.663.664.665.666.667.668.669.670.671.672.673.674.675.676.677.678.679.680.681.682.683.684.685.686.687.688.689.690.691.692.693.694.695.696.697.698.699.700.701.702.703.704.705.706.707.708.709.710.711.712.713.714.715.

/* Navicat MySQL Data Transfer Source Server : hth Source Server Version : 50562 Source Host : localhost:3306 Source Database : pet_store Target Server Type : MYSQL Target Server Version : 50562 File Encoding : 65001 Date: 2021-11-07 20:28:33 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `pet` -- ---------------------------- DROP TABLE IF EXISTS `pet`; CREATE TABLE `pet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `pet_name` varchar(20) NOT NULL, `pet_price` decimal(10,2) NOT NULL, `pet_role_type` int(3) NOT NULL DEFAULT '1' COMMENT '宠物类型:1-普通宠物;2-培育宠物', `pet_type` varchar(20) NOT NULL COMMENT '宠物品种', `owner_id` int(5) NOT NULL, `owner_type` int(5) NOT NULL COMMENT '主人类型:1-个人;2-商店', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of pet -- ---------------------------- INSERT INTO `pet` VALUES ('1', '欢欢', '5.00', '1', '哈士奇', '1', '1'); INSERT INTO `pet` VALUES ('2', '齐齐', '10.00', '1', '藏獒', '4', '2'); INSERT INTO `pet` VALUES ('3', '露露', '20.00', '1', '银渐层', '3', '1'); INSERT INTO `pet` VALUES ('4', '布布1', '5.00', '1', '金毛', '3', '1'); INSERT INTO `pet` VALUES ('5', '布布2', '5.00', '1', '哈士奇', '4', '2'); INSERT INTO `pet` VALUES ('6', '布布3', '5.00', '1', '银渐层', '5', '2'); INSERT INTO `pet` VALUES ('7', '布布4', '5.00', '1', '金毛', '4', '2'); INSERT INTO `pet` VALUES ('8', '布布5', '5.00', '1', '银渐层', '5', '2'); INSERT INTO `pet` VALUES ('9', '布布6', '5.00', '1', '哈士奇', '4', '2'); INSERT INTO `pet` VALUES ('10', '布布7', '5.00', '1', '金毛', '5', '2'); INSERT INTO `pet` VALUES ('11', '龙龙1', '30.00', '2', '哈士奇', '3', '1'); INSERT INTO `pet` VALUES ('12', '龙龙2', '40.00', '2', '银渐层', '5', '2'); INSERT INTO `pet` VALUES ('13', '龙龙3', '50.00', '2', '藏獒', '4', '2'); INSERT INTO `pet` VALUES ('14', '小辉2', '50.00', '2', '金渐层', '4', '2'); INSERT INTO `pet` VALUES ('15', '小辉3', '50.00', '2', '金渐层', '4', '2'); INSERT INTO `pet` VALUES ('16', '小辉4', '50.00', '2', '金渐层', '4', '2'); INSERT INTO `pet` VALUES ('17', '小哈', '50.00', '2', '金渐层', '5', '2'); INSERT INTO `pet` VALUES ('18', '小哈', '5.00', '1', '金渐层', '5', '2');1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.

/* Navicat MySQL Data Transfer Source Server : hth Source Server Version : 50562 Source Host : localhost:3306 Source Database : pet_store Target Server Type : MYSQL Target Server Version : 50562 File Encoding : 65001 Date: 2021-11-07 20:28:44 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `pet_owner` -- ---------------------------- DROP TABLE IF EXISTS `pet_owner`; CREATE TABLE `pet_owner` ( `id` int(11) NOT NULL AUTO_INCREMENT, `owner_id` int(11) NOT NULL, `owner_name` varchar(20) NOT NULL COMMENT '宠物拥有者名称', `owner_type` int(11) NOT NULL DEFAULT '1' COMMENT '主人类型:1-个人;2-商店', `money` decimal(11,0) NOT NULL DEFAULT '0' COMMENT '金币', `address` varchar(30) DEFAULT NULL, `password` varchar(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of pet_owner -- ---------------------------- INSERT INTO `pet_owner` VALUES ('10', '3', 'hth', '1', '9825', '江西', '123'); INSERT INTO `pet_owner` VALUES ('12', '2', '韦德', '1', '14710', '湖北', '123'); INSERT INTO `pet_owner` VALUES ('13', '1', 'kobe', '1', '5000', '山东', '123'); INSERT INTO `pet_owner` VALUES ('14', '4', '重庆观音桥', '2', '332240', '重庆', '123'); INSERT INTO `pet_owner` VALUES ('15', '5', '西苑', '2', '134625', '深圳', '123');1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.

/* Navicat MySQL Data Transfer Source Server : hth Source Server Version : 50562 Source Host : localhost:3306 Source Database : pet_store Target Server Type : MYSQL Target Server Version : 50562 File Encoding : 65001 Date: 2021-11-07 20:28:39 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `account_info` -- ---------------------------- DROP TABLE IF EXISTS `account_info`; CREATE TABLE `account_info` ( `id` int(11) NOT NULL AUTO_INCREMENT, `account_type` varchar(255) DEFAULT NULL, `buy_owner_id` int(11) NOT NULL, `buy_owner_name` varchar(30) DEFAULT NULL, `buy_owner_type` int(11) DEFAULT NULL, `sale_owner_id` int(11) NOT NULL, `sale_owner_type` int(11) DEFAULT NULL, `sale_owner_name` varchar(30) DEFAULT NULL, `pet_id` int(11) NOT NULL, `price` decimal(10,0) DEFAULT NULL, `create_time` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of account_info -- ---------------------------- INSERT INTO `account_info` VALUES ('8', '1', '3', null, null, '4', null, null, '2', '5', '2021-11-07 17:51:38'); INSERT INTO `account_info` VALUES ('9', '1', '3', null, null, '5', null, null, '4', '5', '2021-11-07 17:52:23'); INSERT INTO `account_info` VALUES ('10', '2', '3', null, null, '5', null, null, '3', '20', '2021-11-07'); INSERT INTO `account_info` VALUES ('11', '2', '3', null, null, '4', null, null, '11', '30', '2021-11-07'); INSERT INTO `account_info` VALUES ('12', '2', '3', null, null, '5', null, null, '12', '40', '2021-11-07'); INSERT INTO `account_info` VALUES ('13', '2', '3', null, null, '4', null, null, '13', '50', '2021-11-07'); INSERT INTO `account_info` VALUES ('16', '2', '3', null, null, '4', null, null, '2', '10', '2021-11-07'); INSERT INTO `account_info` VALUES ('17', '1', '3', null, null, '4', null, null, '2', '10', '2021-11-07 20:14:25'); INSERT INTO `account_info` VALUES ('18', '2', '3', null, null, '4', null, null, '11', '30', '2021-11-07'); INSERT INTO `account_info` VALUES ('19', '2', '3', null, null, '4', null, null, '2', '10', '2021-11-07');1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.

相关知识

java宠物商店 jdbc宠物商店
Java入门:用jdbc实现宠物商店管理系统
mysql 项目案例宠物商店
java宠物商店项目
宠物商店 案例分析
宠物商店详细设计说明书
java入门:用jdbc实现宠物商店管理系统续篇
宠物商店中商店购买主人的方法怎样实现
java实例分析宠物商店
解析宠物商店pet

网址: java宠物商店 jdbc宠物商店 https://m.mcbbbk.com/newsview568544.html

所属分类:萌宠日常
上一篇: java开发桌面宠物
下一篇: 基于Java的宠物商店管理系统设