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

📄 classofpets.java~2~

📁 基于mvc的宠物管理系统。servlet+jsp
💻 JAVA~2~
字号:
package com.richard.dao;

import java.util.*;

import com.richard.dao.*;
import com.richard.dto.*;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;

public class ClassOfPets implements InterfaceOfPets {
    DBOperate objDBOperate = new DBOperate();
    public ClassOfPets() {
    }

    /**
     * PetsQueryAll
     *
     * @return ArrayList
     * @todo Implement this com.richard.dao.InterfaceOfPets method
     */
    public ArrayList PetsQueryAll(int perPage, int pageNumber) {
        ArrayList objArrayList = new ArrayList();
        String sqlCommand = "{call proc_pets (?,?)}";
        try {
            CallableStatement cs = objDBOperate.getConnect("petclinic").
                                   prepareCall(sqlCommand);
            cs.setInt(1, perPage);
            cs.setInt(2, pageNumber);
            ResultSet rs = cs.executeQuery();
            while (rs.next()) {
                Pets objPets = new Pets();
                objPets.setId(rs.getInt(1));
                objPets.setName(rs.getString(2));
                objPets.setBirth_date(rs.getString(3));
                objPets.setType_id(rs.getInt(4));
                objPets.setOwner_id(rs.getInt(5));
                objArrayList.add(objPets);

            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return objArrayList;

    }

    /**
     * petsDelete
     *
     * @param objPets Pets
     * @todo Implement this com.richard.dao.InterfaceOfPets method
     */
    public void petsDelete(Pets objPets) {
    }

    /**
     * petsInsert
     *
     * @param objPets Pets
     * @todo Implement this com.richard.dao.InterfaceOfPets method
     */
    public void petsInsert(Pets objPets) {
    }

    /**
     * petsQuery
     *
     * @param objPets Pets
     * @return Pets
     * @todo Implement this com.richard.dao.InterfaceOfPets method
     */
    public Pets petsQuery(Pets objPets) {

        return null;
    }

    /**
     * petsUpdate
     *
     * @param objPets Pets
     * @todo Implement this com.richard.dao.InterfaceOfPets method
     */
    public void petsUpdate(Pets objPets) {
    }

    public int totalPages()

    {
        int totalPages = 0;
        String sqlCommand = "select count(*) from pets";

        try {
            PreparedStatement objStatement = objDBOperate.getPreparedStatement(
                    "petclinic", sqlCommand);
            ResultSet rs = objStatement.executeQuery();
            while (rs.next()) {
                totalPages = rs.getInt(1);
            }

        } catch (Exception ex) {
            System.out.println("错误提示:" + ex.getMessage());
        }
        if (totalPages % 15 == 0) {
            return totalPages / 15;
        } else {
            return (totalPages / 15) + 1;
        }
    }


}

⌨️ 快捷键说明

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