⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbconnect.java~1~

📁 小型宠物医院网站
💻 JAVA~1~
📖 第 1 页 / 共 2 页
字号:
            }
        } catch (Exception ex) {

        }
        return ar;
    }

    public ArrayList getDocBySp(int spId) { //通过专业得到兽医
        ArrayList ar = new ArrayList();
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_DocBySpDis(?)}");
            ps.setInt(1, spId);
            rs = ps.executeQuery();
            DoctorBean doctor;
            while (rs.next()) {
                doctor = new DoctorBean();
                doctor.setDocId(rs.getInt(1));
                String docname = rs.getString(2);
                doctor.setDocName(docname);
                doctor.setDocPhone(rs.getString(3));
                doctor.setDocSpId(this.getSpecid(docname));
                doctor.setDocMessage(rs.getString(4));
                doctor.setDocImage(rs.getString(5));
                ar.add(doctor);

            }
        } catch (Exception ex) {

        }
        return ar;

    }

    public int[] getSpecid(String docnames) { //用兽医姓名得到专业编号
        Connection conn = null;
        int specid[] = new int[4];
        int specids[] = new int[4];
        ResultSet rs = null;
        PreparedStatement ps = null;
        try {
            conn = this.getCon();
            ps = conn.prepareCall("{call proc_SpecByNameDis(?)}");
            ps.setString(1, docnames);
            rs = ps.executeQuery();
            int i = 0;
            while (rs.next()) {
                specid[i] = rs.getInt(2);
                i++;
            }
            specids = new int[i];
            for (int j = 0; j < i; j++) {
                specids[j] = specid[j];
            }

        } catch (Exception ex) {

        }
        return specids;
    }

    public docSpBean getSpecName(int specid) { //用专业编号得到专业名称
        docSpBean spec = new docSpBean();
        Connection con = null;
        ResultSet rs = null;
        PreparedStatement ps = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_SpecByIdDis(?)}");
            ps.setInt(1, specid);
            rs = ps.executeQuery();
            while (rs.next()) {
                spec.setSpId(rs.getInt(1));
                spec.setSpName(rs.getString(2));
                spec.setSpMessage(rs.getString(3));

            }
        } catch (Exception ex) {

        }
        return spec;
    }

    public ArrayList getDocByName(String name) { //按姓名查找兽医
        ArrayList ar = new ArrayList();
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_DocDis(?)}");
            ps.setString(1, name);
            rs = ps.executeQuery();
            DoctorBean doctor;
            while (rs.next()) {
                doctor = new DoctorBean();
                doctor.setDocId(rs.getInt(1));
                String docname = rs.getString(2);
                doctor.setDocName(docname);
                doctor.setDocPhone(rs.getString(3));
                doctor.setDocSpId(this.getSpecid(docname));
                doctor.setDocMessage(rs.getString(4));
                doctor.setDocImage(rs.getString(5));
                ar.add(doctor);
            }
        } catch (Exception ex) {

        }
        return ar;

    }

    public void addDoc(int spId, String docname, String docphone,
                       String docmessage, String docimage) throws Exception  { //增加兽医
        Connection con = null;
        PreparedStatement ps = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_AddDoc(?,?,?,?,?)}");
            ps.setInt(1, spId);
            ps.setString(2, docname);
            ps.setString(3, docphone);
            ps.setString(4, docmessage);
            ps.setString(5, docimage);
            ps.executeUpdate();
        } catch (Exception ex) {
          throw ex;
        }

    }

    public int addSpec(String specname, String specmessage) { //增加专业
        int i = 5;
        Connection con = null;
        PreparedStatement ps = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_AddSpecial(?,?)}");
            ps.setString(1, specname);
            ps.setString(2, specmessage);
            i = ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;
    }

    public int deleteSpec(int id) { //删除专业
        int i = 5;
        Connection con = null;
        PreparedStatement ps = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_DeleteSpecial(?)}");
            ps.setInt(1, id);
            i = ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;
    }

    //宠物操作
    public int addPet(String petname, int ownerid, int typeid, String petimage) { //增加宠物
        int i = 5;
        Connection con = null;
        PreparedStatement ps = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_AddPet(?,?,?,?) }");
            ps.setString(1, petname);
            ps.setInt(2, ownerid);
            ps.setInt(3, typeid);
            ps.setString(4, petimage);
           i= ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;
    }
    public int updatePet(int petId,String petName,int petOwnerId,int petTypeId,String petImage){
        int i=5;
        Connection con=null;
        PreparedStatement ps=null;
        try {
            con=this.getCon();
            ps=con.prepareCall("{call proc_UpdatePet(?,?,?,?,?)}");
            ps.setInt(1,petId);
            ps.setString(2,petName);
            ps.setInt(3,petOwnerId);
            ps.setInt(4,petTypeId);
            ps.setString(5,petImage);
            i=ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;
    }
    public int deletePet(int petid) { //删除宠物
        int i = 5;
        Connection con = null;
        PreparedStatement ps = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_DeletePet(?)}");
            ps.setInt(1, petid);
            i = ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;
    }

    public ArrayList getAllPet() { //得到所有宠物
        ArrayList ar = new ArrayList();
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_AllPetDis}");
            rs = ps.executeQuery();
            petsBean pet = null;
            while (rs.next()) {
                pet = new petsBean();
                pet.setPetId(rs.getInt(1));
                pet.setPetName(rs.getString(2));
                pet.setPetOwnerId(rs.getInt(3));
                pet.setPetTypeId(rs.getInt(4));
                pet.setPetImage(rs.getString(5));
                ar.add(pet);
            }
        } catch (Exception ex) {

        }
        return ar;
    }

    public ArrayList getPetByType(int typeid) { //按类别查询宠物
        ArrayList ar = new ArrayList();
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_PetTypeDis(?)}");
            ps.setInt(1, typeid);
            rs = ps.executeQuery();
            petsBean pet = null;
            while (rs.next()) {
                pet = new petsBean();
                pet.setPetId(rs.getInt(1));
                pet.setPetName(rs.getString(2));
                pet.setPetOwnerId(rs.getInt(3));
                pet.setPetTypeId(rs.getInt(4));
                pet.setPetImage(rs.getString(5));
                ar.add(pet);
            }
        } catch (Exception ex) {

        }
        return ar;

    }

    public ArrayList getPetByOwner(int ownerid) { //按主人查询宠物
        ArrayList ar = new ArrayList();
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            con = this.getCon();
            ps = con.prepareCall("{call proc_PetOwnerDis(?)}");
            ps.setInt(1, ownerid);
            rs = ps.executeQuery();
            petsBean pet = null;
            while (rs.next()) {
                pet = new petsBean();
                pet.setPetId(rs.getInt(1));
                pet.setPetName(rs.getString(2));
                pet.setPetOwnerId(rs.getInt(3));
                pet.setPetTypeId(rs.getInt(4));
                pet.setPetImage(rs.getString(5));
                ar.add(pet);
            }
        } catch (Exception ex) {

        }
        return ar;

    }
    //病历操作
    public int addRecord(int petId,int docId,String message,String reTime){//增加病历
        int i=5;
        Connection con=null;
        PreparedStatement ps=null;
        try {
            con=this.getCon();
            ps=con.prepareCall("{call proc_AddRe(?,?,?,?)}");
            ps.setInt(1,petId);
            ps.setInt(2,docId);
            ps.setString(3,message);
            ps.setString(4,reTime);
            i=ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;

    }
    public int deleteRecord(int recordId){//删除病例
        int i=5;
        Connection con=null;
        PreparedStatement ps=null;
        try {
            con=this.getCon();
            ps=con.prepareCall("{call proc_DeleteRe(?)}");
            ps.setInt(1,recordId);
            i=ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;
    }
    public int updateRecord(int recordId,String recordMessage){
        int i=5;
        Connection con=null;
        PreparedStatement ps=null;
        try {
            con=this.getCon();
            ps=con.prepareCall("{call proc_updateRecord(?,?) }");
            ps.setInt(1,recordId);
            ps.setString(2,recordMessage);
            i=ps.executeUpdate();
        } catch (Exception ex) {

        }
        return i;
    }
    public ArrayList getAllRecord(){//得到所有病例
        ArrayList ar=new ArrayList();
        Connection con=null;
        PreparedStatement ps=null;
        ResultSet rs=null;
        try {
            con=this.getCon();
            ps=con.prepareCall("{call proc_AllRecordDis}");
            rs=ps.executeQuery();
            RecordBean record=null;
            while (rs.next()) {
                record=new RecordBean();
                record.setRecordId(rs.getInt(1));
                record.setPetId(rs.getInt(2));
                record.setDocId(rs.getInt(3));
                record.setRecordMessage(rs.getString(4));
                record.setRecordTime(rs.getString(5));
                ar.add(record);
            }
        } catch (Exception ex) {

        }
        return ar;

    }
    public ArrayList getRecordByPet(int petId){
        ArrayList ar=new ArrayList();
        Connection con=null;
        PreparedStatement ps=null;
        ResultSet rs=null;
        try {
            con=this.getCon();
            ps=con.prepareCall("{call proc_PetRecordDis(?)}");
            ps.setInt(1,petId);
            rs=ps.executeQuery();
            RecordBean record=null;
            while (rs.next()) {
                record=new RecordBean();
                record.setRecordId(rs.getInt(1));
                record.setPetId(rs.getInt(2));
                record.setDocId(rs.getInt(3));
                record.setRecordMessage(rs.getString(4));
                record.setRecordTime(rs.getString(5));
                ar.add(record);
            }
        } catch (Exception ex) {

        }
        return ar;

    }
    public ArrayList getRecordByDoc(int docId){
        ArrayList ar=new ArrayList();
        Connection con=null;
        PreparedStatement ps=null;
        ResultSet rs=null;
        try {
            con=this.getCon();
            ps=con.prepareCall("{call proc_DocRecordDis(?)}");
            ps.setInt(1,docId);
            rs=ps.executeQuery();
            RecordBean record=null;
            while (rs.next()) {
                record=new RecordBean();
                record.setRecordId(rs.getInt(1));
                record.setPetId(rs.getInt(2));
                record.setDocId(rs.getInt(3));
                record.setRecordMessage(rs.getString(4));
                record.setRecordTime(rs.getString(5));
                ar.add(record);
            }
        } catch (Exception ex) {

        }
        return ar;

    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -