/*
* ArticleDaoImplJDBC.java
*
* Created on 2006年9月21日, 下午10:01
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package tot.dao.jdbc;
import tot.dao.AbstractDao;
import tot.dao.DaoFactory;
import tot.global.Sysconfig;
import tot.db.DBUtils;
import tot.bean.*;
import tot.util.StringUtils;
import tot.util.FileUtil;
import tot.util.DateUtil;
import tot.exception.ObjectNotFoundException;
import tot.exception.DatabaseException;
import tot.search.SearchQueryNoSql;
import java.sql.*;
import java.util.*;
import java.io.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
* @author totcms
*/
public class ArticleDaoImplJDBC extends AbstractDao {
private static Log log = LogFactory.getLog(ArticleDaoImplJDBC.class);
/** Creates a new instance of ArticleDaoImplJDBC */
public ArticleDaoImplJDBC() {
}
public int getLastId(){
int returnValue=0;
String sql=null;
DataField df=null;
if (DBUtils.getDatabaseType() == DBUtils.DATABASE_SQLSERVER) {
sql="select top 1 id from t_article order by id desc";
}else if(DBUtils.getDatabaseType() == DBUtils.DATABASE_MYSQL){
sql="select id from t_article order by id desc limit 0,1";
}else if(DBUtils.getDatabaseType()==DBUtils.DATABASE_DB2){
sql="select id from t_article order by id desc fetch first 1 rows only";
}else if(DBUtils.getDatabaseType()==DBUtils.DATABASE_ORACLE){
sql="select id from t_article where rownum=1 order by id desc";
}else{
}
df=getFirstData(sql,"id");
if(df!=null){
returnValue=Integer.parseInt(df.getFieldValue("id"))+1;
} else{
returnValue=1;
}
return returnValue;
}
public int getLastId2() {
int returnValue = 0;
String sql = null;
DataField df = null;
sql = "select id from t_article order by id desc";
Collection lists = this.getDataList_Limit_Normal(sql, "id", 1, 0);
Iterator iter = lists.iterator();
if (iter.hasNext()) {
df = (DataField) iter.next();
}
if (df != null) {
returnValue = Integer.parseInt(df.getFieldValue("id")) + 1;
} else {
returnValue = 1;
}
return returnValue;
}
public int getHits(int id) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
int returnValue = 0;
String sql = null;
sql = "select Hits from t_article where id=?";
try {
conn = DBUtils.getConnection();
ps = conn.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
if (rs.next()) {
returnValue = rs.getInt(1);
} else {
returnValue = 0;
}
} catch (SQLException e) {
log.error("get hits error", e);
} finally {
DBUtils.closeResultSet(rs);
DBUtils.closePrepareStatement(ps);
DBUtils.closeConnection(conn);
}
return returnValue;
}
/** add new article */
public boolean addArticle(String title, String subHeading, String titleColor, String keyWords, String relateKey, int relateNum, String content,
int isOutLink, String outLinkUrl, int parentId, int categoryId, int templateId, int specialId, int top1, int toTop, int toHot,
int recommend, int images, int checked, String author, String sourceFrom, String editor, String userName, String photo, int hits,
String savePath, Timestamp moditime, int isslide, String summary) {
Connection conn = null;
PreparedStatement ps = null;
boolean returnValue = true;
String sql = "insert into t_article(Title,SubHeading,TitleColor,KeyWords,RelateKey,RelateNum,Content,IsOutLink,OutLinkUrl,ParentId," +
"CategoryId,TemplateId,SpecialId,Top1,ToTop,ToHot,Recommend,Images,Checked,Author,SourceFrom,Editor,UserName,Photo,Hits,SavePath,ModiTime,IsSlide,Summary,SortId,ModDate)" +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
try {
conn = DBUtils.getConnection();
conn.setAutoCommit(false);
ps = conn.prepareStatement(sql);
ps.setString(1, title);
ps.setString(2, subHeading);
ps.setString(3, titleColor);
ps.setString(4, keyWords);
ps.setString(5, relateKey);
ps.setInt(6, relateNum);
if (DBUtils.getDatabaseType() == DBUtils.DATABASE_ORACLE) {
ps.setCharacterStream(7, new StringReader(content), content.length());
} else {
ps.setString(7, content);
}
ps.setInt(8, isOutLink);
ps.setString(9, outLinkUrl);
ps.setInt(10, parentId);
ps.setInt(11, categoryId);
ps.setInt(12, templateId);
ps.setInt(13, specialId);
ps.setInt(14, top1);
ps.setInt(15, toTop);
ps.setInt(16, toHot);
ps.setInt(17, recommend);
ps.setInt(18, images);
ps.setInt(19, checked);
ps.setString(20, author);
ps.setString(21, sourceFrom);
ps.setString(22, editor);
ps.setString(23, userName);
ps.setString(24, photo);
ps.setInt(25, hits);
ps.setString(26, savePath);
ps.setTimestamp(27, moditime);
ps.setInt(28, isslide);
ps.setString(29, summary);
ps.setInt(30,getLastId());
ps.setString(31,DateUtil.getStringDate());
if (ps.executeUpdate() != 1) {
returnValue = false;
}
conn.commit();
conn.setAutoCommit(true);
} catch (SQLException e) {
if(conn!=null){
try {
conn.rollback();
conn.setAutoCommit(true);
log.error("add Article error", e);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
} finally {
DBUtils.closePrepareStatement(ps);
DBUtils.closeConnection(conn);
}
return returnValue;
}
/*
* mod Article
*/
public boolean modArticle(int id, String title, String subHeading, String titleColor, String keyWords, String relateKey, int relateNum, String content,
int isOutLink, String outLinkUrl, int parentId, int categoryId, int templateId, int specialId, int top1, int toTop, int toHot,
int recommend, int images, int checked, String author, String sourceFrom, String editor, String userName, String photo, int hits,
String savePath, Timestamp moditime, int isslide, String summary,int sortid,String moddate) {
Connection conn = null;
PreparedStatement ps = null;
boolean returnValue = true;
String sql = "update t_article set Title=?,SubHeading=?,TitleColor=?,KeyWords=?,RelateKey=?,RelateNum=?,Content=?,IsOutLink=?," +
"OutLinkUrl=?,ParentId=?,CategoryId=?,TemplateId=?,SpecialId=?,Top1=?,ToTop=?,ToHot=?,Recommend=?,Images=?," +
"Checked=?,Author=?,SourceFrom=?,Editor=?,UserName=?,Photo=?,Hits=?,SavePath=?,IsSlide=?,Summary=?,SortId=?,ModDate=? where id=?";
try {
conn = DBUtils.getConnection();
conn.setAutoCommit(false);
ps = conn.prepareStatement(sql)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
淘特JspCms内容管理系统tot-jsp-cms (2000个子文件)
class_upload.asp 6KB
class_upload.asp 6KB
commands.asp 5KB
connector.asp 3KB
upload.asp 3KB
io.asp 2KB
basexml.asp 2KB
config.asp 2KB
config.asp 1KB
util.asp 1KB
io.asp 697B
connector.aspx 959B
upload.aspx 930B
connector.cfm 11KB
upload.cfm 6KB
spellchecker.cfm 5KB
config.cfm 3KB
config.cfm 3KB
connector.cgi 3KB
jquery-ui-1.10.3.custom.css 31KB
jquery-ui-1.10.3.custom.min.css 27KB
global.css 10KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
s.css 7KB
calendar-mos.css 4KB
dhtmlgoodies_calendar.css 3KB
dhtmlgoodies_calendar.css 3KB
index.css 3KB
show.css 3KB
show.css 3KB
index.css 3KB
show.css 3KB
list.css 2KB
list.css 2KB
index.css 2KB
show.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
ctcstd.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
pages.css 2KB
list.css 2KB
fck_editorarea.css 2KB
fck_editorarea.css 2KB
fck_internal.css 2KB
fck_internal.css 2KB
global.css 2KB
browser.css 2KB
browser.css 2KB
fck_dialog_common.css 2KB
fck_dialog_common.css 2KB
tabpane.css 1KB
editor.css 1KB
fck_showtableborders_gecko.css 1KB
fck_showtableborders_gecko.css 1KB
stylesheet.css 1KB
list.css 1KB
fck_universalkey.css 1KB
fck_universalkey.css 1KB
global.css 901B
spellerStyle.css 888B
spellerStyle.css 888B
global.css 536B
head.css 286B
css.css 75B
Thumbs.db 30KB
Thumbs.db 13KB
Thumbs.db 6KB
Thumbs.db 5KB
Thumbs.db 3KB
Thumbs.db 3KB
Thumbs.db 3KB
淘特JspCms内容管理系统.doc 1.94MB
系统使用流程及标签说明.doc 61KB
ffmpeg.exe 22.75MB
fck_strip.gif 8KB
fck_strip.gif 4KB
fck_strip.gif 4KB
keyboard_layout.gif 3KB
logo_fckeditor.gif 2KB
htm.gif 1KB
html.gif 1KB
rdp.gif 1KB
flv.gif 1KB
ai.gif 1KB
embaressed_smile.gif 1KB
teeth_smile.gif 1KB
shades_smile.gif 1KB
file.gif 1KB
tounge_smile.gif 1KB
wink_smile.gif 1KB
sad_smile.gif 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
流华追梦
- 粉丝: 5625
- 资源: 2507
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MyBatisCodeHelperPro 3.3.2-2322 2023.2-2024.1
- 基于Python的简单的学生成绩管理程序设计(课程设计)
- jdk-8u20-windows-x64安装版本-jdk-8u301-linux-x64解压版
- 植物大战僵尸杂交版 修改阳光和冷却
- html css js网页设计ntion-model-for-开发笔记
- 数据库课程设计-processing开发笔记
- matlab画图sic-开发demo
- 数据库原理课程设计-图书馆数据库管理系统
- IEC101Sim IEC870-5-101协议仿真主站、子站 (含源码 C++Builder)
- 2212503007陈熙炜跨境2202作业2.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功