本文共 4111 字,大约阅读时间需要 13 分钟。
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;/** * 新闻类别实现类 * * @author Administrator * */public class categoryTBDaoImpl extends BaseDao implements categoryTBDao { // 查询 public List getCategoryTBAll() { String sql = "select categoryID,categoryName from categoryTB"; List typelist = new ArrayList (); try { ResultSet rs = executeQurey(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) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { closeAll(); } return typelist; } // 添加 public int addCategory(categoryTB cate) { int rel = 0; String sql = "insert categoryTB (categoryName) values(?)"; List
转载地址:http://irktz.baihongyu.com/