package org.fly.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import org.fly.beans.Bbs;
import org.fly.beans.Bbslink;
import org.fly.beans.Bbsnews;
import org.fly.beans.Board;
import org.fly.beans.Bookmark;
import org.fly.beans.Classtype;
import org.fly.beans.Config;
import org.fly.beans.Friend;
import org.fly.beans.Log;
import org.fly.beans.Message;
import org.fly.beans.Online;
import org.fly.beans.User;
import org.fly.beans.Vote;
public class ControlDB {
/***************************************************************************
* 查询论坛中的帖子信息
*
* @param sql
* 数据库查询语句
* @return List 返回结果--List类型
* @throws Exception
* 向上抛错误
*/
public List executeQueryBbs(String sql) throws Exception {
ResultSet rs = null;
List list = new ArrayList();
Connection con = null;
Statement stmt = null;
try {
con = ConnectionFactory.getConnection();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Bbs bbs = new Bbs();
int i = 1;
bbs.setAnnounceID(rs.getInt(i++));// 获取ID
bbs.setParentID(rs.getInt(i++));// 获取主论坛ID
bbs.setChild(rs.getInt(i++));// 获取子论坛ID
bbs.setBoardID(rs.getInt(i++));// 获取帖子ID
bbs.setUserName(rs.getString(i++));// 获取帖子作者
bbs.setUserEmail(rs.getString(i++));// 作者Email
bbs.setTopic(rs.getString(i++));// 作者头像
bbs.setTitle(rs.getString(i++));// 帖子标题
bbs.setBody(rs.getString(i++));// 帖子内容
bbs.setDateAndTime(rs.getString(i++));// 发帖时间
bbs.setHits(rs.getInt(i++));// 点击率
bbs.setIp(rs.getString(i++));// 发贴者IP
bbs.setExpression(rs.getString(i++));// 作者经验值
bbs.setIstop(rs.getInt(i++));// 是否为置顶帖子
bbs.setIslock(rs.getInt(i++));// 是否锁定帖子
bbs.setIsgood(rs.getInt(i++));// 是否为精华
bbs.setIsvote(rs.getInt(i++));// 是否为投票贴
bbs.setHeart(rs.getString(i++));// 帖子心情
bbs.setType(rs.getString(i++));// 帖子类别
bbs.setLastre(rs.getString(i++));// 最后回复时间
list.add(bbs);// 将结果加入到List中以便返回
}
} catch (Exception e) {
throw e;
} finally {
DatabaseUtils.closeObject(rs, stmt, con);
}
return list;
}
/***************************************************************************
* 日前还用不上
*
* @param sql
* @return
* @throws Exception
*/
public List executeQueryBbslink(String sql) throws Exception {
ResultSet rs = null;
List list = new ArrayList();
Connection con = null;
Statement stmt = null;
try {
con = ConnectionFactory.getConnection();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Bbslink bbslink = new Bbslink();
int i = 1;
bbslink.setId(rs.getInt(i++));
bbslink.setBoardname(rs.getString(i++));
bbslink.setReadme(rs.getString(i++));
bbslink.setUrl(rs.getString(i++));
list.add(bbslink);// 将结果加入到List中以便返回
}
} catch (Exception e) {
throw e;
} finally {
DatabaseUtils.closeObject(rs, stmt, con);
}
return list;
}
/***************************************************************************
* 论坛公告信息
*
* @param sql
* @return
* @throws Exception
*/
public List executeQueryBbsnews(String sql) throws Exception {
ResultSet rs = null;
List list = new ArrayList();
Connection con = null;
Statement stmt = null;
try {
con = ConnectionFactory.getConnection();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Bbsnews bbsnews = new Bbsnews();
int i = 1;
bbsnews.setId(rs.getInt(i++));// 主键ID
bbsnews.setBoardid(rs.getInt(i++));// 公告位于那个版块
bbsnews.setTitle(rs.getString(i++));// 公告标题
bbsnews.setContent(rs.getString(i++));// 公告内容
bbsnews.setUsername(rs.getString(i++));// 发布者
bbsnews.setAddtime(rs.getString(i++));// 发布时间
list.add(bbsnews);// 将结果加入到List中以便返回
}
} catch (Exception e) {
throw e;
} finally {
DatabaseUtils.closeObject(rs, stmt, con);
}
return list;
}
/***************************************************************************
* 论坛版块信息查询
*
* @param sql
* 查询语句
* @return List 返回List
* @throws Exception
* 向上抛错误
*/
public List executeQueryBoard(String sql) throws Exception {
ResultSet rs = null;
List list = new ArrayList();
Connection con = null;
Statement stmt = null;
try {
con = ConnectionFactory.getConnection();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Board board = new Board();
int i = 1;
board.setBoardid(rs.getInt(i++));// 主键ID
board.setBoardType(rs.getString(i++));// 论坛名称
board.setClassType(rs.getInt(i++));// 所属主论坛类别
board.setReadme(rs.getString(i++));// 论坛简介
board.setModerid(rs.getInt(i++)); //版主ID
board.setBoardMaster(rs.getString(i++));// 管理员
board.setLockboard(rs.getInt(i++)); // 是否锁定
board.setForumlogo(rs.getString(i++));// 论坛Logo
board.setIndexIMG(rs.getString(i++));// 首页论坛图片
board.setLastrootid(rs.getInt(i++));// 最后发帖ID
board.setLasttitle(rs.getString(i++)); // 最后帖子标题
board.setBoarduser(rs.getString(i++));// 最后帖子作者
board.setLastposttime(rs.getString(i++));// 最后帖子时间
list.add(board);// 将结果加入到List中以便返回
}
} catch (Exception e) {
throw e;
} finally {
DatabaseUtils.closeObject(rs, stmt, con);
}
return list;
}
/**
* 未知方法
*
* @param sql
* @return
* @throws Exception
*/
public List executeQueryBookmark(String sql) throws Exception {
ResultSet rs = null;
List list = new ArrayList();
Connection con = null;
Statement stmt = null;
try {
con = ConnectionFactory.getConnection();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Bookmark bookmark = new Bookmark();
int i = 1;
bookmark.setId(rs.getInt(i++));
bookmark.setUsername(rs.getString(i++));
bookmark.setUrl(rs.getString(i++));
bookmark.setTopic(rs.getString(i++));
bookmark.setAddtime(rs.getString(i++));
list.add(bookmark);// 将结果加入到List中以便返回
}
} catch (Exception e) {
throw e;
} finally {
DatabaseUtils.closeObject(rs, stmt, con);
}
return list;
}
/***************************************************************************
* 论坛类别信息
*
* @param sql
* 查询语句
* @return List
* @throws Exception
*/
public List executeQueryClasstype(String sql) throws Exception {
ResultSet rs = null;
List list = new ArrayList();
Connection con = null;
Statement stmt = null;
try {
con = ConnectionFactory.getConnection();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
while (rs.next()) {
Classtype classtype = new Classtype();
int i = 1;
classtype.setId(rs.getInt(i++));// 主键ID
classtype.setClassType(rs.getString(i++));// 论坛类别
list.add(classtype);// 将结果加入到List中以便返回
}
} catch (Exception e) {
throw e;
} finally {
DatabaseUtils.closeObject(rs, stmt, con);
}
return list;
}
/***************************************************************************
* 网站信息管理
*
* @param sql
* @return
* @throws Exception
*/
public List executeQueryConfig(String sql) throws Exception {
ResultSet rs = null;
List list = new ArrayList();
Connection con = null;
S