package org.jbit.news.dao.impl;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jbit.news.dao.BaseDao;
import org.jbit.news.dao.NewsDao;
public class NewsDaoImpl extends BaseDao implements NewsDao {
public List getAllnews(){
openConnection();
List list = new ArrayList();
String sql = "select *"
+ " from news,topic"
+ " where news.ntid = topic.tid"
+ " order by ntid,ncreatedate desc";
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm");
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
Map news = new HashMap();
news.put("ncontent", rs.getString("ncontent"));
news.put("nsummary", rs.getString("nsummary"));
news.put("nid", String.valueOf(rs.getObject("nid")));
news.put("ntid", String.valueOf(rs.getObject("ntid")));
news.put("ntitle", rs.getString("ntitle"));
news.put("nauthor", rs.getString("nauthor"));
news.put("tname", rs.getString("tname"));
news.put("ncreatedate", sdf.format(rs.getObject("ncreatedate")));
news.put("npicpath", rs.getString("npicpath"));
list.add(news);
}
}catch (SQLException e) {
e.printStackTrace();
}finally{
closeResource();
}
return list;
}
public List getNewsByType(int page_info_no, int page_no){
openConnection();
List list = new ArrayList();
String sql = "select * "
+ "from (select b.*, rownum r"
+ " from (select * from news,topic where news.ntid = topic.tid order by news.ncreatedate desc) b "
+ " where rownum < " + (page_info_no*(page_no)) + ") t "
+ " where t.r >" + (page_info_no*(page_no-1));
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm");
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
Map news = new HashMap();
news.put("ncontent", rs.getString("ncontent"));
news.put("nsummary", rs.getString("nsummary"));
news.put("nid", String.valueOf(rs.getObject("nid")));
news.put("ntid", String.valueOf(rs.getObject("ntid")));
news.put("ntitle", rs.getString("ntitle"));
news.put("nauthor", rs.getString("nauthor"));
news.put("tname", rs.getString("tname"));
news.put("ncreatedate", sdf.format(rs.getObject("ncreatedate")));
news.put("npicpath", rs.getString("npicpath"));
list.add(news);
}
}catch (SQLException e) {
e.printStackTrace();
}finally{
closeResource();
}
return list;
}
public List getAllnewsByPage(int page_info_no, int page_no){
openConnection();
List list = new ArrayList();
String sql = "select * "
+ "from (select b.*, rownum r"
+ " from (select * from news,topic where news.ntid = topic.tid order by news.ncreatedate desc) b "
+ " where rownum < " + (page_info_no*(page_no)) + ") t "
+ " where t.r >" + (page_info_no*(page_no-1));
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm");
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
Map news = new HashMap();
news.put("ncontent", rs.getString("ncontent"));
news.put("nsummary", rs.getString("nsummary"));
news.put("nid", String.valueOf(rs.getObject("nid")));
news.put("ntid", String.valueOf(rs.getObject("ntid")));
news.put("ntitle", rs.getString("ntitle"));
news.put("nauthor", rs.getString("nauthor"));
news.put("tname", rs.getString("tname"));
news.put("ncreatedate", rs.getObject("ncreatedate"));
news.put("npicpath", rs.getString("npicpath"));
list.add(news);
}
}catch (SQLException e) {
e.printStackTrace();
}finally{
closeResource();
}
return list;
}
public List getAllnewsByPageAndTid(int page_info_no, int page_no, String tid){
openConnection();
List list = new ArrayList();
String sql = "select * "
+ "from (select b.*, rownum r"
+ " from (select * from news,topic where news.ntid = topic.tid and tid = " + tid + " order by news.ncreatedate desc) b "
+ " where rownum < " + (page_info_no*(page_no)) + ") t "
+ " where t.r >" + (page_info_no*(page_no-1));
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm");
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
Map news = new HashMap();
news.put("ncontent", rs.getString("ncontent"));
news.put("nsummary", rs.getString("nsummary"));
news.put("nid", String.valueOf(rs.getObject("nid")));
news.put("ntid", String.valueOf(rs.getObject("ntid")));
news.put("ntitle", rs.getString("ntitle"));
news.put("nauthor", rs.getString("nauthor"));
news.put("tname", rs.getString("tname"));
news.put("ncreatedate", sdf.format(rs.getObject("ncreatedate")));
news.put("npicpath", rs.getString("npicpath"));
list.add(news);
}
}catch (SQLException e) {
e.printStackTrace();
}finally{
closeResource();
}
return list;
}
public int countNews(){
openConnection();
int count = 0;
String sql = "select count(*)"
+ " from news";
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
count = rs.getInt(1);
}
}catch (SQLException e) {
e.printStackTrace();
}finally{
closeResource();
}
return count;
}
public Map getNewsByNid(String nid){
openConnection();
Map news = null;
String sql = "select *"
+ " from news,topic"
+ " where news.ntid = topic.tid and nid = "
+ nid;
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm");
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
news = new HashMap();
news.put("ncontent", rs.getString("ncontent"));
news.put("nsummary", rs.getString("nsummary"));
news.put("nid", String.valueOf(rs.getObject("nid")));
news.put("ntid", String.valueOf(rs.getObject("ntid")));
news.put("ntitle", rs.getString("ntitle"));
news.put("nauthor", rs.getString("nauthor"));
news.put("tname", rs.getString("tname"));
news.put("ncreatedate", sdf.format(rs.getObject("ncreatedate")));
news.put("npicpath", rs.getString("npicpath"));
}
}catch (SQLException e) {
e.printStackTrace();
}finally{
closeResource();
}
return news;
}
public List getNewByTid(String tid){
openConnection();
List list = new ArrayList();
String sql = "select *"
+ " from news,topic"
+ " where news.ntid = topic.tid and topic.tid = "
+ tid
+ " order by ncreatedate desc";
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm");
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
Map news = new HashMap();
news.put("ncontent", rs.getString("ncontent"));
news.put("nsummary", rs.getString("nsummary"));
news.put("nid", String.valueOf(rs.getObject("nid")));
news.put("ntid", String.valueOf(rs.getObject("ntid")));
news.put("ntitle", rs.getString("ntitle"));
news.put("nauthor", rs.getString("nauthor"));
news.put("tname", rs.getString("tname"));
news.put("ncreatedate", sdf.format(rs.getObject("ncreatedate")));
news.put("npicpath", rs.getString("npicpath"));
list.add(news);
}
}catch (SQLException e) {
e.printStackTrace();
}finally{
closeResource();
}
return list;
}
public int updateNews(Map news) {
openConnection();
String sql = "update news set ntid=?, ntitle=?, nauthor=?, npicpath=?, ncontent=?, nmodifydate=?, nsummary=? "
+ "where nid = " + news.get("nid");
int update_rows = 0;
try {
java.util.Date d
没有合适的资源?快使用搜索试试~ 我知道了~
News-release-system.rar_news release system _oracle
共106个文件
gif:23个
jsp:21个
java:18个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 4 浏览量
2022-09-24
17:37:41
上传
评论
收藏 2.64MB RAR 举报
温馨提示
新闻发布系统,使用JSP和ORACLE开发的
资源详情
资源评论
资源推荐
收起资源包目录
News-release-system.rar_news release system _oracle (106个子文件)
NewsDaoImpl.class 9KB
TopicsDaoImpl.class 4KB
CommentsDaoImpl.class 4KB
News.class 2KB
NewsBizImpl.class 2KB
BaseDao.class 2KB
CommentControl.class 2KB
TopicBizImpl.class 2KB
Comment.class 1KB
CommentsBizImpl.class 1KB
User.class 889B
Topic.class 710B
NewsDao.class 556B
NewsBiz.class 469B
TopicBiz.class 467B
TopicsDao.class 413B
CommentsBiz.class 302B
CommentsDao.class 301B
.classpath 694B
admin.css 3KB
main.css 3KB
read.css 3KB
main-1.gif 290KB
head.gif 40KB
a_b01.gif 40KB
class_bg.gif 6KB
sidebarbg.gif 5KB
class_type.gif 4KB
title_3.gif 4KB
title_1.gif 4KB
title_2.gif 3KB
friend_ico.gif 3KB
opt_name.gif 3KB
channel_bg.gif 1KB
friend_logo.gif 1KB
login_sub.gif 987B
login_input.gif 504B
firend_bg.gif 343B
topbg.gif 195B
admin_bar.gif 191B
friend_t.gif 189B
opt_sub.gif 180B
nav_leftdot.gif 82B
nav_leftline.gif 53B
arrow.gif 50B
index_bottom.html 933B
bottom.html 816B
index_rightbar.html 510B
left.html 246B
classes12.jar 1.14MB
sqljdbc.jar 570KB
standard.jar 384KB
jstl.jar 20KB
smartupload.jar 15KB
NewsDaoImpl.java 10KB
TopicsDaoImpl.java 4KB
CommentsDaoImpl.java 2KB
News.java 2KB
BaseDao.java 1KB
NewsBizImpl.java 1KB
CommentControl.java 1013B
Comment.java 969B
TopicBizImpl.java 908B
NewsDao.java 761B
CommentsBizImpl.java 730B
TopicsDao.java 510B
User.java 510B
TopicBiz.java 458B
NewsBiz.java 449B
Topic.java 371B
CommentsDao.java 345B
CommentsBiz.java 277B
Picture1.jpg 51KB
Picture2.jpg 50KB
Picture4.jpg 47KB
Picture3.jpg 31KB
banner.jpg 20KB
logo.jpg 14KB
left.jpg 6KB
logo1.jpg 2KB
news_modify.jsp 5KB
news_read.jsp 4KB
index.jsp 3KB
admin.jsp 3KB
topic_list.jsp 3KB
news_add.jsp 3KB
do_update_news.jsp 2KB
do_add_news.jsp 2KB
index_top.jsp 2KB
index_sidebar.jsp 2KB
do_add_comment.jsp 2KB
topic_modify.jsp 1KB
top.jsp 1KB
do_update_topic.jsp 1001B
topic_add.jsp 955B
do_delete_comments.jsp 917B
do_add_topic.jsp 907B
do_login.jsp 893B
do_delete_topics.jsp 827B
do_delete_news.jsp 810B
共 106 条
- 1
- 2
我虽横行却不霸道
- 粉丝: 75
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0