// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name: News.java
package StudyNews;
import java.io.PrintStream;
import java.sql.ResultSet;
import java.util.Vector;
// Referenced classes of package StudyNews:
// DB, Type
public class News
{
public News()
{
}
public void setId(int id)
{
this.id = id;
}
public void setTitle(String title)
{
this.title = title;
}
public void setContent(String content)
{
this.content = content;
}
public void setAuthor(String author)
{
this.author = author;
}
public void setTime(String time)
{
this.time = time;
}
public void setKeyword(String keyword)
{
this.keyword = keyword;
}
public void setType(int type)
{
this.type = type;
}
public void setViewCount(int viewCount)
{
this.viewCount = viewCount;
}
public int getId()
{
return id;
}
public String getTitle()
{
return title;
}
public String getContent()
{
return content;
}
public String getAuthor()
{
return author;
}
public String getTime()
{
return time;
}
public String getKeyword()
{
return keyword;
}
public int getType()
{
return type;
}
public int getViewCount(){
return viewCount;
}
public boolean Insert(DB db)
throws Exception
{
String strSql = "Select max(id) From news";
ResultSet rs = db.OpenSql(strSql);
int iMaxId;
if(rs.next())
iMaxId = rs.getInt(1) + 1;
else
iMaxId = 1;
strSql = "insert into news values(" + iMaxId + ",'" + title + "','" + content + "','" + author + "',getdate(),'" + keyword + "'," + type + ")";
return db.ExecSql(strSql) != 0;
}
public boolean Edit(DB db)
throws Exception
{
String strSql = "update news set title='" + title + "'," + " content='" + content + "'," + " author='" + author + "'," + " keyword='" + keyword + "'," + " type=" + type + " where id=" + id;
return db.ExecSql(strSql) != 0;
}
public static Vector SearchNewsTitle(DB db)
throws Exception
{
Vector newsType = new Vector();
String strSql = null;
strSql = "select * from type";
Vector newsList;
for(ResultSet typeRs = db.OpenSql(strSql); typeRs.next(); System.out.println("newsList: " + newsList.size()))
{
Type type = new Type();
type.setTypeId(typeRs.getInt("typeId"));
type.setTypeName(typeRs.getString("typeName"));
newsList = new Vector();
newsList.add(type);
strSql = "select top 5* from news where type=" + typeRs.getInt("typeId") + " order by time desc";
News news;
for(ResultSet newsRs = db.OpenSql(strSql); newsRs.next(); newsList.add(news))
{
news = new News();
news.setId(newsRs.getInt("id"));
news.setTitle(newsRs.getString("title"));
news.setTime(newsRs.getString("time"));
news.setType(newsRs.getInt("type"));
}
newsType.add(newsList);
}
System.out.println("\nnewsType: " + newsType.size());
return newsType;
}
public static Vector SearchNewsTitle(DB db, int typeId, int pageId)
throws Exception
{
Vector newsType = new Vector();
String strSql = null;
strSql = "select * from type where typeid=" + typeId;
Vector newsList;
for(ResultSet typeRs = db.OpenSql(strSql); typeRs.next(); System.out.println("newsList: " + newsList.size()))
{
Type type = new Type();
type.setTypeId(typeRs.getInt("typeId"));
type.setTypeName(typeRs.getString("typeName"));
newsList = new Vector();
newsList.add(type);
strSql = "select * from news where type=" + typeId + " order by time desc";
ResultSet newsRs = db.OpenSql(strSql);
int iCount = 0;
int iCurRecord = pageId * 10 + 1;
if(newsRs.absolute(iCurRecord)){
do
{
News news = new News();
news.setId(newsRs.getInt("id"));
news.setTitle(newsRs.getString("title"));
news.setTime(newsRs.getString("time"));
news.setType(newsRs.getInt("type"));
newsList.add(news);
} while(++iCount < 10 && newsRs.next());
}
newsType.add(newsList);
}
System.out.println("\nnewsType: " + newsType.size());
strSql = "select * from type where typeid<>" + typeId;
Type type;
for(ResultSet typeRs = db.OpenSql(strSql); typeRs.next(); newsType.add(type))
{
type = new Type();
type.setTypeId(typeRs.getInt("typeId"));
type.setTypeName(typeRs.getString("typeName"));
}
System.out.println("\nnewsType: " + newsType.size());
return newsType;
}
public static Vector SearchNewsTitle(DB db, int typeId, int pageId,String keyword)
throws Exception
{
Vector newsType = new Vector();
String strSql = null;
strSql = "select * from type where typeid=" + typeId;
Vector newsList;
for(ResultSet typeRs = db.OpenSql(strSql); typeRs.next(); System.out.println("newsList: " + newsList.size()))
{
Type type = new Type();
type.setTypeId(typeRs.getInt("typeId"));
type.setTypeName(typeRs.getString("typeName"));
newsList = new Vector();
newsList.add(type);
strSql = "select * from news where type=" + typeId +" and( title like '%"+keyword+"%' )"+" order by time desc";
ResultSet newsRs = db.OpenSql(strSql);
int iCount = 0;
int iCurRecord = pageId * 10 + 1;
if(newsRs.absolute(iCurRecord)){
do
{
News news = new News();
news.setId(newsRs.getInt("id"));
news.setTitle(newsRs.getString("title"));
news.setTime(newsRs.getString("time"));
news.setType(newsRs.getInt("type"));
newsList.add(news);
System.out.println("------------"+newsRs.getString("title"));
} while(++iCount < 10 && newsRs.next());
}
newsType.add(newsList);
}
System.out.println("\nnewsType: " + newsType.size());
strSql = "select * from type where typeid<>" + typeId;
Type type;
for(ResultSet typeRs = db.OpenSql(strSql); typeRs.next(); newsType.add(type))
{
type = new Type();
type.setTypeId(typeRs.getInt("typeId"));
type.setTypeName(typeRs.getString("typeName"));
}
System.out.println("\nnewsType: " + newsType.size());
return newsType;
}
public static Vector SearchRelativeNews(DB db, int newsId, String keyword)
throws Exception
{
Vector newsList = new Vector();
String strSql = null;
strSql = "select * from news where id<>" + newsId + " and keyword like '%" + keyword + "%' order by time desc";
News news;
for(ResultSet rs = db.OpenSql(strSql); rs.next(); newsList.add(news))
{
news = new News();
news.setId(rs.getInt("id"));
news.setTitle(rs.getString("title"));
news.setTime(rs.getString("time"));
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于Struts的新闻发布系统
共118个文件
jsp:24个
jar:19个
java:17个
需积分: 0 41 下载量 168 浏览量
2008-12-13
01:15:10
上传
评论 1
收藏 2.79MB RAR 举报
温馨提示
本项目是基于Struts的新闻发布系统。
资源详情
资源评论
资源推荐
收起资源包目录
基于Struts的新闻发布系统 (118个子文件)
News.class 8KB
NewsAddAction.class 4KB
NewsEditSubmitAction.class 3KB
AdminLoginAction.class 3KB
TypeDetailAction.class 3KB
NewsDelAction.class 3KB
TypeAdminDetailAction.class 3KB
DetailAction.class 3KB
NewsEditAction.class 2KB
AdminAction.class 2KB
AdminUser.class 2KB
FirstAction.class 2KB
DB.class 2KB
Type.class 2KB
NewsPreAddAction.class 1KB
MyRequestProcessor.class 967B
Constants.class 752B
.classpath 2KB
public.css 11KB
index.css 1KB
struts-config.exadel 8KB
top_03.gif 12KB
top_01.gif 4KB
top_06.gif 3KB
top_04.gif 2KB
ladyhot.gif 1KB
top_05.gif 1KB
article1.gif 826B
DOT.GIF 514B
new3[1].gif 320B
201.gif 264B
button.gif 184B
note.gif 156B
del.gif 152B
more.gif 113B
struts.jar 514KB
standard.jar 384KB
antlr.jar 379KB
msbase.jar 278KB
commons-collections-2.1.1.jar 171KB
commons-collections.jar 167KB
commons-beanutils.jar 116KB
commons-digester.jar 107KB
commons-dbcp.jar 105KB
commons-validator.jar 82KB
jakarta-oro.jar 64KB
mssqlserver.jar 63KB
commons-lang.jar 62KB
msutil.jar 58KB
commons-pool.jar 41KB
commons-logging.jar 31KB
commons-fileupload.jar 22KB
jstl.jar 21KB
struts-legacy.jar 10KB
News.java 10KB
NewsAddAction.java 2KB
AdminLoginAction.java 2KB
NewsEditSubmitAction.java 2KB
TypeDetailAction.java 2KB
DB.java 2KB
TypeAdminDetailAction.java 2KB
AdminUser.java 2KB
NewsDelAction.java 2KB
DetailAction.java 1KB
Type.java 1KB
NewsEditAction.java 1KB
AdminAction.java 1KB
FirstAction.java 1KB
MyRequestProcessor.java 900B
Constants.java 896B
NewsPreAddAction.java 744B
top_02.jpg 30KB
r3.jpg 637B
203.jpg 489B
202.jpg 340B
typeDetial.jsp 3KB
newsAdminMain.jsp 3KB
newsTypeAdminMain.jsp 3KB
newsMain.jsp 2KB
newsAdminLogin.jsp 2KB
newsContent.jsp 2KB
newsEdit.jsp 1KB
footer.jsp 1KB
newsAdd.jsp 1KB
header.jsp 702B
template.jsp 542B
wrong.jsp 525B
newsTypeAdminMain_show.jsp 353B
newsAdminLogin_show.jsp 350B
newsAdminMain_show.jsp 349B
newsEdit_show.jsp 344B
newsAdd_show.jsp 343B
newsContent_show.jsp 337B
typeDetial_show.jsp 336B
newsMain_show.jsp 334B
wrong_show.jsp 331B
aboutus_show.jsp 323B
aboutus.jsp 274B
index.jsp 59B
online_Log.LDF 1024KB
共 118 条
- 1
- 2
naturalsea
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- STC15单片机串口2使用程序例子
- 读取日志的excel生成周报 用python3开发weekplan-master.zip
- python 读取excel数据导入dbimport-data-master.zip
- K折交叉验证BP神经网络,多输入多输出BP神经网络(代码完整,数据齐全)
- B07训练原图.zip
- python-对Excel数据处理做可视化分析.zip
- 人工智能大作业-无人机图像目标检测的python源代码+文档说明.zip
- 基于GoogLeNet实现Cifar-10图像分类项目python源码(高分项目).zip
- 数据库 sql 面试题目及答案解析.docx
- 汽车常见 10 种传感器故障后的表现与解决措施.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0