package com.jjzd.news.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.jjzd.news.dao.BaseDao;
import com.jjzd.news.dao.bm_comment;
import com.jjzd.news.entity.Comment;
public class bm_commentImpl extends BaseDao implements bm_comment {
@Override
// 是否存在评论表
public boolean isComExist() {
String sql = "select * from com limit 1";
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = getConnection();
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
if (rs!=null) {
System.out.println("true");
return true; // 表存在
} else {
System.out.println("false");
return false; // 表不存在
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println("异常");
return false; // 出现异常,表不存在
} finally {
// 关闭资源
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
@Override
//创建评论表(username,ip,comment)
public int createCom() {
String createTableSql = "create table com (id VARCHAR(50), name VARCHAR(50), content VARCHAR(255))";
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement(createTableSql);
return ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
return 0;
} finally {
// 关闭资源
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
@Override
public List<com.jjzd.news.entity.bm_comment> getallCom() {
List<com.jjzd.news.entity.bm_comment> commentList = new ArrayList<>();
String sql = "select * from com";
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = getConnection();
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
String id = rs.getString("id");
String name = rs.getString("name");
String content = rs.getString("content");
com.jjzd.news.entity.bm_comment com = new com.jjzd.news.entity.bm_comment(name, id, content);
commentList.add(com);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭资源
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
System.out.println("yes");
System.out.println(commentList);
return commentList;
}
//添加评论
@Override
public int addCom(String id, String name, String content) {
String sql = "insert into com(id, name, content) values(?,?,?)";
exceuteUpdate(sql, id, name, content);
return 0;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
新闻系统项目资源,包含数据库文件、jsp文件、java文件
共98个文件
gif:23个
jsp:23个
java:14个
2 下载量 81 浏览量
2023-12-23
13:37:07
上传
评论
收藏 1.39MB ZIP 举报
温馨提示
数据库文件用于存储新闻数据和相关信息,JSP文件负责前端页面的展示和交互,而Java文件则实现了后端的业务逻辑和数据处理。这些资源的结合使得新闻系统能够高效地管理和展示新闻内容,为用户提供优质的新闻阅读体验。无论是数据库文件的设计、JSP文件的布局还是Java文件的编写,都是项目成功运行的关键要素,它们共同构成了一个完整的新闻系统
资源推荐
资源详情
资源评论
收起资源包目录
新闻系统项目演示.zip (98个子文件)
新闻系统项目演示
news
.classpath 825B
src
com
jjzd
news
dao
TopicsDao.java 588B
UserDao.java 184B
NewsDao.java 424B
bm_comment.java 423B
impl
UserDaoImpl.java 944B
bm_commentImpl.java 4KB
NewsDaoImpl.java 2KB
TopicsDaoImpl.java 3KB
BaseDao.java 2KB
entity
Comment.java 976B
News.java 2KB
bm_comment.java 862B
Topic.java 336B
User.java 475B
.idea
workspace.xml 2KB
misc.xml 280B
build
classes
com
jjzd
news
dao
UserDao.class 200B
BaseDao.class 2KB
bm_comment.class 366B
NewsDao.class 390B
impl
UserDaoImpl.class 2KB
TopicsDaoImpl.class 4KB
bm_commentImpl.class 4KB
NewsDaoImpl.class 3KB
TopicsDao.class 460B
entity
User.class 893B
Topic.class 714B
bm_comment.class 1KB
News.class 3KB
Comment.class 1KB
WebContent
index-elements
index_bottom.html 964B
index_rightbar.html 541B
WEB-INF
lib
mysql-connector-java-5.1.16-bin.jar 768KB
web.xml 304B
index.jsp 9KB
css
main.css 3KB
admin.css 3KB
read.css 3KB
newspages
news_read.jsp 9KB
news_add.jsp 2KB
news_delte.jsp 743B
topic_add.jsp 1KB
topic_list.jsp 1KB
console_element
top.jsp 1KB
bottom.html 895B
left.html 291B
news_modify.jsp 2KB
admin.jsp 2KB
topic_modify.jsp 1KB
topic_delte.jsp 801B
images
blue_bar.png 942B
title_1.gif 4KB
a_b01.gif 40KB
Picture4.jpg 47KB
Picture1.jpg 51KB
banner.jpg 20KB
Picture2.jpg 50KB
friend_logo.gif 1KB
admin_bar.gif 191B
nav_leftdot.gif 82B
firend_bg.gif 343B
login_input.gif 504B
login_sub.gif 987B
topbg.gif 195B
title_2.gif 3KB
friend_t.gif 189B
opt_sub.gif 180B
class_type.gif 4KB
main-1.gif 290KB
arrow.gif 50B
friend_ico.gif 3KB
Picture3.jpg 31KB
title_3.gif 4KB
nav_leftline.gif 53B
logo.jpg 14KB
class_bg.gif 6KB
head.gif 40KB
logo1.jpg 2KB
sidebarbg.gif 5KB
channel_bg.gif 1KB
opt_name.gif 3KB
left.jpg 6KB
util
do_login.jsp 693B
do_topic_modify.jsp 857B
do_topic_list.jsp 403B
do_xinwen.jsp 927B
do_add_topic.jsp 830B
do_getnews.jsp 3KB
do_news_modify.jsp 1KB
do_news_list.jsp 381B
pinglun.jsp 654B
do_news_delte.jsp 807B
do_add_news.jsp 1000B
do_topic_delte.jsp 234B
META-INF
MANIFEST.MF 39B
.project 904B
test.sql 2KB
共 98 条
- 1
资源评论
Benmao
- 粉丝: 511
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功