classoftypes.java

来自「基于mvc的宠物管理系统。servlet+jsp」· Java 代码 · 共 89 行

JAVA
89
字号
package com.richard.dao;

import java.util.*;
import java.sql.ResultSet;
import com.richard.dto.*;


public class ClassOfTypes implements InterfaceOfTypes {
    DBOperate objDBOperate = new DBOperate();
    public ClassOfTypes() {
    }

    /**
     * typesDelete
     *
     * @param objTypes Types
     * @todo Implement this com.richard.dao.InterfaceOfTypes method
     */
    public void typesDelete(Types objTypes) {
    }

    /**
     * typesInsert
     *
     * @param objTypes Types
     * @todo Implement this com.richard.dao.InterfaceOfTypes method
     */
    public void typesInsert(Types objTypes) {
    }

    /**
     * typesQuery
     *
     * @param objTypes Types
     * @return Types
     * @todo Implement this com.richard.dao.InterfaceOfTypes method
     */
    public Types typesQuery(Types objTypes) {
        return null;
    }

    /**
     * typesQueryAll
     *
     * @return ArrayList
     * @todo Implement this com.richard.dao.InterfaceOfTypes method
     */
    public ArrayList typesQueryAll() {
        String sqlCommand = "select * from types";
        ArrayList objArrayList = new ArrayList();
        ResultSet rs = objDBOperate.getResultSet("petclinic", sqlCommand);
        try {
            while (rs.next()) {
                Types objTypes = new Types();
                objTypes.setId(rs.getInt(1));
                objTypes.setName(rs.getString(2));
                objArrayList.add(objTypes);
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return objArrayList;
    }

    /**
     * typesUpdate
     *
     * @param objTypes Types
     * @todo Implement this com.richard.dao.InterfaceOfTypes method
     */
    public void typesUpdate(Types objTypes) {
    }

    public int nameForId(String name)
    {
        String sqlCommand = "select id from types where name='" + name + "'";
        int id = 0;
        try {
            ResultSet rs = objDBOperate.getResultSet("petclinic", sqlCommand);
            while (rs.next()) {
                id = rs.getInt(1);
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return id;
    }
}

⌨️ 快捷键说明

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