新闻发布系统
news_id=?"; try {
con = DBConnector.getConnection(); ps = con.prepareStatement(sql); ps.setString(1, news_type); ps.setString(2, news_keys); ps.setString(3, news_author); ps.setString(4, news_origin); ps.setString(5, news_content); ps.setString(6, news_title); ps.setInt(7, news_read); ps.setString(8, news_time); ps.setString(9, news_id);
int result = ps.executeUpdate(); if (result != 0) { b = true; }
} catch (SQLException e) { e.printStackTrace(); }finally{
DBConnector.free(rs, ps, con); }
return b; }
3.3.3 删除新闻:
功能:删除指定新闻
实现:根据该新闻ID删除记录,成功返回true,否则返回false. public boolean deleteNews(String news_id){ boolean b = false; try {
con = DBConnector.getConnection();
ps = con.prepareStatement("delete from news where news_id=?");
ps.setString(1, news_id); if(ps.executeUpdate()!=0){ b=true; }
} catch (SQLException e) { e.printStackTrace(); }finally{
DBConnector.free(rs, ps, con); }
return b;