package com.chapter12;
import java.sql.*;
public class Article extends ExecuteDB
{
//定义类成员变量
private long ArticleID;
private String Title;
private String Content;
private long UserID;
private long BoardID;
private long FatherID;
private int ReadCount;
private int ReCount;
private String PicUrl;
private String PicName;
private String CreateTime;
private String strSql;
//构造函数,对成员变量进行初始化赋值
public Article()
{
this.ArticleID=0;
this.Title="";
this.Content="";
this.BoardID=0;
this.ReCount=0;
this.ReadCount=0;
this.PicUrl="";
this.PicName="";
this.FatherID=0;
this.UserID=0;
java.util.Date NowTime = new java.util.Date();
this.CreateTime = NowTime.toLocaleString();
this.strSql="";
}
//添加新文章,往articles数据表中添加一条新记录
public boolean add()
{
this.strSql="insert into articles ";
this.strSql=this.strSql + "(";
this.strSql=this.strSql + "Title,Content,UserID,BoardID,FatherID,ReadCount,ReCount,PicUrl,PicName,CreateTime)";
this.strSql=this.strSql + "values('" + this.Title + "','" + this.Content + "','" + this.UserID + "','" + this.BoardID + "','" + this.FatherID + "','" + this.ReadCount + "','" + this.ReCount + "','" + this.PicUrl + "','" + this.PicName + "','" + this.CreateTime + "')";
boolean isAdd = super.exeSql(this.strSql);
return isAdd;
}
//删除ArticleID对应的文章的信息
public boolean delete()
{
this.strSql="delete from `articles` where ArticleID='";
this.strSql=this.strSql + this.ArticleID + "'";
boolean isDelete = super.exeSql(this.strSql);
return isDelete;
}
//验证ArticleID和UserID是否匹配
public boolean valid()
{
this.strSql="select ArticleID from `articles` ";
this.strSql=this.strSql + " where ArticleID='" + this.ArticleID + "'";
this.strSql=this.strSql + " and UserID='"+ this.UserID + "'";
System.out.println(this.strSql);
try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//获取ArticleID对应的文章的信息,将这些信息赋值给相应的类变量
public boolean init()
{
this.strSql="select * from `articles` where ArticleID=";
this.strSql=this.strSql + "'" + this.ArticleID + "'";
try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
ArticleID=rs.getLong("ArticleID");
Title=rs.getString("Title");
Content=rs.getString("Content");
BoardID=rs.getLong("BoardID");
FatherID=rs.getLong("FatherID");
ReadCount=rs.getInt("ReadCount");
UserID=rs.getLong("UserID");
ReCount=rs.getInt("ReCount");
PicUrl=rs.getString("PicUrl");
PicName=rs.getString("PicName");
CreateTime=rs.getString("CreateTime");
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//获得FatherID相同的一组文章的信息,返回一个ResultSet类型对象
public ResultSet show_son_articles()
{
this.strSql="select * from `articles`";
this.strSql=this.strSql + " where FatherID = '" + this.FatherID + "'";
ResultSet rs = null;
try
{
rs = super.exeQuery(this.strSql);
}
catch(Exception e)
{
System.out.println(e.toString());
}
return rs;
}
//获得BoardID对应的讨论区的所有主贴的文章信息,返回一个ResultSet类型对象
public ResultSet show_board_articles()
{
this.strSql="select ArticleID,Title,UserID,ReadCount,ReCount,CreateTime from `articles`";
this.strSql=this.strSql + " where BoardID = '" + this.BoardID + "'";
this.strSql=this.strSql + " and FatherID = '0' order by CreateTime desc";
ResultSet rs = null;
try
{
rs = super.exeQuery(this.strSql);
}
catch(Exception e)
{
System.out.println(e.toString());
}
return rs;
}
//获得BoardID对应的讨论区的所有主贴的数量
public int articles_count()
{
this.strSql="select ArticleID,Title,UserID,ReadCount,ReCount,CreateTime from `articles`";
this.strSql=this.strSql + " where BoardID = '" + this.BoardID + "'";
this.strSql=this.strSql + " and FatherID = '0'";
ResultSet rs = null;
try
{
rs = super.exeQuery(this.strSql);
rs.last();
return rs.getRow();
}
catch(Exception e)
{
System.out.println(e.toString());
return 0;
}
}
//更改articles数据表中ArticleID所对应的ReadCount的值
public boolean modify_ReadCount()
{
this.strSql="update articles set";
this.strSql=this.strSql + " ReadCount = '"+this.ReadCount+"'";
this.strSql=this.strSql + " where ArticleID='" + this.ArticleID + "'";
boolean isModify = super.exeSql(this.strSql);
return isModify;
}
//更改articles数据表中ArticleID所对应的ReCount的值
public boolean modify_ReCount()
{
this.strSql="update articles set";
this.strSql=this.strSql + " ReCount = '"+this.ReCount+"'";
this.strSql=this.strSql + " where ArticleID='" + this.ArticleID + "'";
boolean isModify = super.exeSql(this.strSql);
return isModify;
}
//设置类成员变量ArticleID的值
public void setArticleID(long ArticleID)
{
this.ArticleID = ArticleID;
}
//获取类成员变量ArticleID的值
public long getArticleID()
{
return this.ArticleID;
}
//设置类成员变量Title的值
public void setTitle(String Title)
{
this.Title = Title;
}
//获取类成员变量Title的值
public String getTitle()
{
return this.Title;
}
//设置类成员变量Content的值
public void setContent(String Content)
{
this.Content = Content;
}
//获取类成员变量Content的值
public String getContent()
{
return this.Content;
}
//设置类成员变量UserID的值
public void setUserID(long UserID)
{
this.UserID = UserID;
}
//获取类成员变量UserID的值
public long getUserID()
{
return this.UserID;
}
//设置类成员变量BoardID的值
public void setBoardID(long BoardID)
{
this.BoardID = BoardID;
}
//获取类成员变量BoardID的值
public long getBoardID()
{
return this.BoardID;
}
//设置类成员变量FatherID的值
public void setFatherID(long FatherID)
{
this.FatherID = FatherID;
}
//获取类成员变量FatherID的值
public long getFatherID()
{
return this.FatherID;
}
//设置类成员变量CreateTime的值
public void setCreateTime(String CreateTime)
{
this.CreateTime = CreateTime;
}
//获取类成员变量CreateTime的值
public String getCreateTime()
{
return this.CreateTime;
}
//设置类成员变量ReadCount的值
public void setReadCount(int ReadCount)
{
this.ReadCount = ReadCount;
}
//获取类成员变量ReadCount的值
public int getReadCount()
{
return this.ReadCount;
}
//设置类成员变量ReCount的值
public void setReCount(int ReCount)
{
this.ReCount = ReCount;
}
//获取类成员变量ReCount的值
public int getReCount()
{
return this.ReCount;
}
//设置类成员变量PicUrl的值
public void setPicUrl(String PicUrl)
{
this.PicUrl = PicUrl;
}
//获取类成员变量PicUrl的值
public String getPicUrl()
{
return this.PicUrl;
}
//设置类成员变量PicName的值
public void setPicName(String PicName)
{
this.PicName = PicName;
}
//获取类成员变量PicName的值
public String getPicName()
{
return this.PicName;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
CH12.rar (50个子文件)
CH12
chapter12
delete_email.jsp 1KB
modify_password_save.jsp 2KB
user_reg_form.html 2KB
article_list.jsp 4KB
WEB-INF
web.xml 1022B
lib
mysql-connector-java-3.1.11-bin.jar 430KB
jspSmartUpload.jar 15KB
classes
Email.java 4KB
Article.java 8KB
SplitPage.java 2KB
com
chapter12
SplitPage.class 2KB
User.class 4KB
Article.class 5KB
ExecuteDB.class 1KB
ConnectDB.class 1KB
SessionCounter.class 614B
Email.class 3KB
Board.class 2KB
ConnectDB.java 952B
User.java 6KB
ExecuteDB.java 1KB
Board.java 3KB
modify_info_save.jsp 1KB
board_list.jsp 1KB
send_email_form.jsp 3KB
manager
add_board_form.jsp 704B
modify_board_save.jsp 1KB
board_management.jsp 2KB
top.jsp 1KB
main.jsp 812B
add_board_save.jsp 1KB
modify_board_form.jsp 1KB
delete_board.jsp 1KB
delete_article.jsp 2KB
article_detail.jsp 4KB
add_article_form.jsp 3KB
image.jsp 2KB
top.jsp 1KB
pic
main.jsp 806B
email_management.jsp 2KB
info_management.jsp 3KB
send_email_save.jsp 1KB
add_article_save.jsp 3KB
index.html 1KB
user_reg_save.jsp 2KB
logout.jsp 143B
email_detail.jsp 2KB
lib
bbs.css 446B
user_login.jsp 1KB
chapter12.sql 2KB
共 50 条
- 1
mjl200509
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页