JSP+Servlet+Tomcat个人博客系统


里面包含了可运行的工程文件,数据库文件SQL Server 2005的,Tomcat6.x的运行文件。内含设计说明文档。这个系统包含了博客的一般功能。
资源截图
代码片段和文件信息
package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import toolsbean.DB;
import valuebean.ArticleBean;

public class ArticleDao {
private DB connection = null;
private ArticleBean articleBean = null;

public ArticleDao() {
connection = new DB();
}

/**
 * @功能 实现对文章进行增、删、改的操作
 * @参数 oper为一个String类型变量,用来表示要进行的操作;single为ArticleBean类对象,用来存储某个文章的信息
 * @返回值 boolean型值
 */
public boolean operationArticle(String oper ArticleBean single) {
/* 生成SQL语句 */
String sql = null;
if (oper.equals(“add“)) //发表新文章
sql = “insert into tb_article values (‘“ + single.getTypeId() + “‘‘“+ single.gettitle() + “‘‘“ + single.getContent() + “‘‘“+ single.getSdTime()+ “‘‘“+single.getCreate()+“‘‘“ + single.getInfo()+“‘“+single.getCount() + “)“;
if (oper.equals(“modify“)) //修改文章
sql = “update tb_article set article_typeID=“ + single.getTypeId()+ “article_title=‘“ + single.gettitle() + “‘article_content=‘“+ single.getContent() +“‘article_create=‘“+single.getCreate()+ “‘article_info=‘“+single.getInfo()+“‘ where id=“ + single.getId();
if (oper.equals(“delete“)) //删除文章
sql = “delete from tb_article where id=“ + single.getId();
if (oper.equals(“readTimes“)) //累加阅读次数
sql = “update tb_article set article_count=article_count+1 where id=“+ single.getId();

/* 执行SQL语句 */
boolean flag =connection.executeUpdate(sql);
return flag;
}

/** 
 * @功能 查询指定类别的文章
 * @参数 typeId表示文章类别ID值
 * @返回值 List集合
 */
public List queryArticle(int typeIdString type) {
List articlelist = new ArrayList();
String sql = ““;
if (typeId <=0) //不按类别查询,查询出前3条记录
sql = “select top 3 * from tb_article order by article_sdTime DESC“;
else //按类别查询
if(type==null||type.equals(““)||!type.equals(“all“))
sql = “select top 5 * from tb_article where article_typeID=“ + typeId+ “ order by article_sdTime DESC“;
else
sql = “select * from tb_article where article_typeID=“ + typeId+ “ order by article_sdTime DESC“;
ResultSet rs = connection.executeQuery(sql);
if(rs!=null){
try {
while (rs.next()) {
/* 获取文章信息 */
articleBean = new ArticleBean();
articleBean.setId(rs.getInt(1));
articleBean.setTypeId(rs.getInt(2));
articleBean.settitle(rs.getString(3));
articleBean.setContent(rs.getString(4));
articleBean.setSdTime(rs.getString(5));
articleBean.setCreate(rs.getString(6));
articleBean.setInfo(rs.getString(7));
articleBean.setCount(rs.getInt(8));

/* 查询tb_review数据表统计当前文章的评论数 */
sql=“select count(id) from tb_review where review_articleId=“+articleBean.getId();
ResultSet rsr=connection.executeQuery(sql);
if(rsr!=null){
rsr.next();
articleBean.setReview(rsr.getInt(1));
rsr.close();
}
articlelist.add(articleBean);
}
} catch (SQLException e) {
e.printSta

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-05-10 19:18  datebase
     文件     1835008  2013-05-10 19:18  datebasedb_Blog_Data.MDF
     文件     1048576  2013-05-10 19:18  datebasedb_Blog_Log.LDF
     文件     1499804  2013-05-10 17:13  Java综合项目实践说明书.wps
     文件       11879  2013-05-04 16:22  jspsmartupload.jar
     目录           0  2013-05-10 19:19  myblog 服务器端
     目录           0  2013-05-10 19:19  myblog 服务器端admin
     文件         687  2013-05-06 13:32  myblog 服务器端adminAdminIndex.jsp
     目录           0  2013-05-10 19:19  myblog 服务器端adminarticle
     文件        3331  2013-05-06 20:18  myblog 服务器端adminarticleArticleAdd.jsp
     文件        3457  2013-05-05 15:07  myblog 服务器端adminarticleArticleList.jsp
     文件        4454  2013-05-05 15:07  myblog 服务器端adminarticleArticleModify.jsp
     文件        2165  2013-05-05 15:07  myblog 服务器端adminarticleArticleSingle.jsp
     文件        1660  2013-05-05 15:07  myblog 服务器端adminarticleArticleTypeAdd.jsp
     文件        2080  2013-05-05 15:07  myblog 服务器端adminarticleArticleTypeList.jsp
     文件        2151  2013-05-05 15:07  myblog 服务器端adminarticleArticleTypeModify.jsp
     文件        1111  2013-05-05 15:07  myblog 服务器端adminerror.jsp
     目录           0  2013-05-10 19:19  myblog 服务器端adminfriend
     文件        2174  2013-05-05 15:07  myblog 服务器端adminfriendFriendAdd.jsp
     文件        2254  2013-05-05 15:07  myblog 服务器端adminfriendFriendList.jsp
     文件        2975  2013-05-05 15:07  myblog 服务器端adminfriendFriendModify.jsp
     文件        2104  2013-05-05 15:07  myblog 服务器端adminfriendFriendSingle.jsp
     文件        1530  2013-05-05 15:07  myblog 服务器端adminlogon.jsp
     目录           0  2013-05-10 19:19  myblog 服务器端adminmaster
     文件         583  2013-05-05 15:07  myblog 服务器端adminmasterMyModify.jsp
     文件         540  2013-05-05 15:07  myblog 服务器端adminmasterMySingle.jsp
     目录           0  2013-05-10 19:19  myblog 服务器端adminphoto
     文件        2551  2013-05-05 15:07  myblog 服务器端adminphotoPhotoList.jsp
     文件         540  2013-05-05 15:07  myblog 服务器端adminphotoPhotoModify.jsp
     文件         540  2013-05-05 15:07  myblog 服务器端adminphotoPhotoSingle.jsp
     文件        1619  2013-05-05 15:07  myblog 服务器端adminphotoPhotoUpload.jsp
............此处省略266个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)