本文共 3412 字,大约阅读时间需要 11 分钟。
package bdqn.newsMange.Dao.Impl;
import java.sql.ResultSet;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;import bdqn.newsMange.Dao.BaseDao;import bdqn.newsMange.Dao.categoryTBDao;import bdqn.newsMange.entity.categoryTB;
/**
???????????*/public class categoryTBDaoImpl extends BaseDao implements categoryTBDao {
// ??????public List
getAllCategories() {String sql = "select categoryID, categoryName from categoryTB";List typelist = new ArrayList<>();try {ResultSet rs = executeQuery(sql, null);while (rs.next()) {categoryTB cate = new categoryTB();cate.setCategoryID(rs.getInt(1));cate.setCategoryName(rs.getString(2));typelist.add(cate);}} catch (ClassNotFoundException e) {e.printStackTrace();} catch (SQLException e) {e.printStackTrace();} finally {closeAll();}return typelist;} // ????public int addCategory(categoryTB cate) {int rel = 0;String sql = "insert into categoryTB (categoryName) values (?)";List
转载地址:http://irktz.baihongyu.com/