給前臺的下拉框賦值

List<LabelValueBean> list = equipScrapDAO.getScrapTypeList();

public List<LabelValueBean> getScrapTypeList() throws SQLException {
        List<LabelValueBean> list = new ArrayList<LabelValueBean>();
        String sql = "select SCRAP_TYPE,SCRAP_TYPE_NAME from SYS_Scrap_Type";
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            conn = getConnection();
            pstmt = conn.prepareStatement(sql);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                LabelValueBean bean = new LabelValueBean();
                bean.setValue(rs.getString("SCRAP_TYPE"));
                bean.setLabel(rs.getString("SCRAP_TYPE_NAME"));
                list.add(bean);
            }
        } finally {
            close(rs, pstmt, conn);
        }
        return list;
    }
相關文章
相關標籤/搜索