package com.accp.lqc.news.model.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import com.accp.lqc.news.model.entity.oneNews;
import com.accp.lqc.news.model.entity.twoNews;
public class twoNewsDAO
{
/***
* 添加2级标题
* @param two
* @return
*/
public static int addTwo(twoNews two)
{
Connection con=null;
PreparedStatement pstmt=null;
int count=0;
try
{
con=DBUtil.getCon();
String sql="insert into SecondLevelTitle values(?,?,?,?,?)";
pstmt=con.prepareStatement(sql);
pstmt.setString(1, two.getTitleName());
pstmt.setString(2, two.getFilePath());
pstmt.setString(3, two.getCreater());
pstmt.setString(4, two.getCreatTime());
pstmt.setInt(5, two.getParentTitle());
count=pstmt.executeUpdate();
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
DBUtil.closeCon(null, pstmt, con);
}
return count;
}
/***
* 查询2级标题
* @return
*/
public static ArrayList gettwoAll() {
ArrayList list = null;
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DBUtil.getCon();
String sql = "select * from SecondLevelTitle";
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
list = new ArrayList();
while(rs.next()) {
twoNews two = new twoNews();
two.setId(rs.getInt("id"));
two.setTitleName(rs.getString("titleName"));
two.setFilePath(rs.getString("filePath"));
two.setCreater(rs.getString("creater"));
two.setCreatTime(rs.getString("creatTime"));
two.setParentTitle(rs.getInt("parentTitle"));
list.add(two);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
DBUtil.closeCon(rs, pstmt, con);
}
return list;
}
/***
* 根据ID查询2级信息
* @param id
* @return
*/
public static twoNews queryBytwoId(int id) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
twoNews two = null;
try {
con = DBUtil.getCon();
String sql = "select * from SecondLevelTitle where id = ?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, id);
rs = pstmt.executeQuery();
if(rs.next()) { //next():游标向下移动
two = new twoNews();
two.setId(rs.getInt("id"));
two.setTitleName(rs.getString("titleName"));
two.setFilePath(rs.getString("filePath"));
two.setCreater(rs.getString("creater"));
two.setCreatTime(rs.getString("creatTime"));
two.setParentTitle(rs.getInt("parentTitle"));
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
DBUtil.closeCon(rs, pstmt, con);
}
return two;
}
/***
* 2级标题删除
* @param id
* @return
*/
public static int deleteTwonews(String id) {
Connection con = null;
PreparedStatement pstmt = null;
int Count = 0;
try {
con = DBUtil.getCon();
String sql = "delete from SecondLevelTitle where id = ?";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, id);
Count = pstmt.executeUpdate();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
DBUtil.closeCon(null, pstmt, con);
}
return Count;
}
/***
* 修改2级标题
* @param one
* @return
*/
public static int updateTwonews(twoNews two) {
Connection con = null;
PreparedStatement pstmt = null;
int Count = 0;
try {
con = DBUtil.getCon();
String sql = "update SecondLevelTitle set TitleName=?,filePath=?,parentTitle=? where id = ?";
pstmt = con.prepareStatement(sql);
pstmt.setString(1,two.getTitleName());
pstmt.setString(2,two.getFilePath());
pstmt.setInt(3,two.getParentTitle());
pstmt.setInt(4,two.getId());
Count = pstmt.executeUpdate();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
DBUtil.closeCon(null, pstmt, con);
}
return Count;
}
/***
*
* @param parent
* @return
*/
/* public static twoNews queryByParent(int parent) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
twoNews two = null;
try {
con = DBUtil.getCon();
String sql = "select TitleName from SecondLevelTitle where ParentTitle=?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, parent);
rs = pstmt.executeQuery();
if(rs.next()) { //next():游标向下移动
two = new twoNews();
two.setTitleName(rs.getString("titleName"));
//two.setParentTitle(rs.getInt("ParentTitle"));
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
DBUtil.closeCon(rs, pstmt, con);
}
return two;
}*/
/**
* 获得指定页的记录
* @param pages:第几页
* @param pageSize:每一页的大小
* @return
*/
public static ArrayList getPageResults(int pages, int pageSize) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ArrayList list = null;
try {
con = DBUtil.getCon();
String sql = "select top " + pageSize + " * from SecondLevelTitle where id not in (select top " + (pages - 1) * pageSize + " id from SecondLevelTitle)";
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
list = new ArrayList();
while(rs.next()) {
twoNews two=new twoNews();
two.setId(rs.getInt("id"));
two.setTitleName(rs.getString("titleName"));
two.setFilePath(rs.getString("filePath"));
two.setCreater(rs.getString("creater"));
two.setCreatTime(rs.getString("creatTime"));
two.setParentTitle(rs.getInt("parentTitle"));
list.add(two);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
DBUtil.closeCon(rs, pstmt, con);
}
return list;
}
/**
* 获得总的记录条数
* @return
*/
public static int getRows() {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int rows = 0;
try {
con = DBUtil.getCon();
String sql = "select count(*) from SecondLevelTitle";
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next()) {
rows = rs.getInt(1);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
DBUtil.closeCon(rs, pstmt, con);
}
return rows;
}
/***
* 总的页数
* @param pageSize
* @return
*/
public static int getTotalPages(int pageSize) {
int totalPage = 0;
int rows = getRows();
int temp = 0;
temp = rows % pageSize;
if(temp == 0) {
totalPage = rows / pageSize;
} else {
totalPage = rows / pageSize + 1;
}
return totalPage;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
news.rar_jsp 新闻发布_jsp 新闻发布系统_jsp 源码_jsp 鏂伴椈_news jsp
共854个文件
gif:434个
jpg:126个
htm:97个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 102 浏览量
2022-09-20
15:10:03
上传
评论
收藏 4.88MB RAR 举报
温馨提示
jsp开发的新闻发布系统的源码,好用而且实用的代码。accp5.0s2源码
资源详情
资源评论
资源推荐
收起资源包目录
news.rar_jsp 新闻发布_jsp 新闻发布系统_jsp 源码_jsp 鏂伴椈_news jsp (854个子文件)
oneNewsDAO.class 5KB
twoNewsDAO.class 5KB
userInfoDAO.class 3KB
twoServlet.class 2KB
oneServlet.class 2KB
updateTwonews.class 2KB
userinfoServlet.class 2KB
updateOnenews.class 2KB
updeteUser.class 2KB
userAddServlet.class 2KB
dengluServlet.class 2KB
DBUtil.class 2KB
deleteUser.class 2KB
deleteTwonews.class 2KB
deleteOnenews.class 2KB
twoNews.class 2KB
oneNews.class 1KB
userInfo.class 964B
.classpath 681B
style.css 9KB
style.css 9KB
style.css 9KB
style.css 9KB
variablesAndContainers.dat 519B
Thumbs.db 152KB
Thumbs.db 63KB
Thumbs.db 62KB
Thumbs.db 56KB
Thumbs.db 32KB
Thumbs.db 8KB
Thumbs.db 5KB
Thumbs.db 5KB
Thumbs.db 5KB
main-1.gif 290KB
main-1.gif 290KB
banner.gif 89KB
banner.gif 89KB
banner1.gif 62KB
banner1.gif 62KB
banner1_03.gif 48KB
banner_03.gif 48KB
banner_03.gif 48KB
banner1_03.gif 48KB
head.gif 40KB
head.gif 40KB
Img225715842.gif 35KB
login.gif 19KB
login.gif 19KB
27114768.gif 16KB
27114773.gif 14KB
27114773.gif 14KB
27114773.gif 14KB
27114773.gif 14KB
27114773.gif 14KB
27114773.gif 14KB
21399_585-50.gif 14KB
banner1_01.gif 12KB
banner_01.gif 12KB
banner_01.gif 12KB
banner1_01.gif 12KB
22911_120x320.gif 11KB
22911_120x320.gif 11KB
22911_120x320.gif 11KB
22911_120x320.gif 11KB
22911_120x320.gif 11KB
Img225903165.gif 11KB
51754.gif 10KB
51754.gif 10KB
51754.gif 10KB
51754.gif 10KB
88576.gif 10KB
88576.gif 10KB
88576.gif 10KB
88576.gif 10KB
36178.gif 9KB
36178.gif 9KB
36178.gif 9KB
36178.gif 9KB
36178.gif 9KB
99455.gif 9KB
99455.gif 9KB
99455.gif 9KB
99455.gif 9KB
login_1.gif 9KB
login_1.gif 9KB
sms_flinders11.gif 9KB
sms_flinders11.gif 9KB
sms_flinders11.gif 9KB
sms_flinders11.gif 9KB
sms_flinders11.gif 9KB
60155.gif 9KB
60155.gif 9KB
60155.gif 9KB
60155.gif 9KB
60155.gif 9KB
20050513_100x100.gif 8KB
99463.gif 8KB
27114691.gif 8KB
52857.gif 8KB
Img225850289.gif 8KB
共 854 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
邓凌佳
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0