📄 f0e0d0499c93001d1e83dbb907bd12f8
字号:
package bbs.dao;
import java.beans.Statement;
import java.sql.*;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
//import sun.security.mscapi.KeyStore.MY;
import bbs.bean.threadBean;
import bbs.bean.threadUse;
import bbs.dao.userDao;
public class threadDao {
public ArrayList<threadBean> gettread(){
ArrayList<threadBean> ar=new ArrayList<threadBean>();
PreparedStatement pt=null;
ResultSet rs=null;
Connection con=conn.getInstance();
try {
pt=con.prepareStatement("select * from BBSthread");
rs=pt.executeQuery();
while(rs.next()){
threadBean th=new threadBean();
th.setThreadID(rs.getInt(1));
th.setForumName(rs.getString(2));
th.setClickDate(rs.getString(3));
th.setCreateDate(rs.getString(4));
th.setClickSum(rs.getInt(5));
th.setReplySum(rs.getInt(6));
th.setUserID(rs.getInt(7));
th.setDeep(rs.getInt(8));
ar.add(th);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
rs.close();
pt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return ar;
}
public ArrayList<threadUse> getmod1(){
ArrayList<threadUse> al=new ArrayList<threadUse>();
java.sql.Statement ps=null;
ResultSet rs=null;
Connection con=conn.getInstance();
try {
String str=MessageFormat.format("select BBSthread.threadID" +
",BBSthread.forumName , BBSmessage.title ," +
" BBSUserInfo.userNickName , BBSthread.clickSum,"+
"BBSthread.replySum, BBSmessage.deep ," +
"BBSmessage.flag from BBSUserInfo,BBSmessage " +
",BBSthread where " +
"BBSmessage.userid = BBSUserInfo.userid and " +
"BBSmessage.forumID = BBSthread.threadID " +
"and BBSthread.threadID={0}"+
"order by messageID desc",1);
ps= con.createStatement();
rs=ps.executeQuery(str);
while(rs.next()){
threadUse tu=new threadUse();
tu.setThreadID(rs.getInt(1));
tu.setForumName1(rs.getString(2));
tu.setTitle(rs.getString(3));
tu.setUserNickName1(rs.getString(4));
tu.setClickSum(rs.getInt(5));
tu.setReplySum1(rs.getInt(6));
tu.setDeep(rs.getInt(7));
tu.setFlag1(rs.getString(8));
tu.setDeep(rs.getInt(8));
al.add(tu);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
rs.close();
ps.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return al;
}
public ArrayList<threadBean> gettitle(){
ArrayList<threadBean> ar=new ArrayList<threadBean>();
PreparedStatement pt=null;
ResultSet rs=null;
Connection con=conn.getInstance();
try {
pt=con.prepareStatement("select * from BBSthread where deep=0");
rs=pt.executeQuery();
while(rs.next()){
threadBean th=new threadBean();
th.setThreadID(rs.getInt(1));
th.setForumName(rs.getString(2));
th.setClickDate(rs.getString(3));
th.setCreateDate(rs.getString(4));
th.setClickSum(rs.getInt(5));
th.setReplySum(rs.getInt(6));
th.setUserID(rs.getInt(7));
th.setDeep(rs.getInt(8));
ar.add(th);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
rs.close();
pt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return ar;
}
public ArrayList<threadBean> gettwotitle(int deep){
ArrayList<threadBean> ar=new ArrayList<threadBean>();
PreparedStatement pt=null;
ResultSet rs=null;
Connection con=conn.getInstance();
try {
pt=con.prepareStatement("select * from BBSthread where deep=?");
pt.setInt(1, deep);
rs=pt.executeQuery();
while(rs.next()){
threadBean th=new threadBean();
th.setThreadID(rs.getInt(1));
th.setForumName(rs.getString(2));
th.setClickDate(rs.getString(3));
th.setCreateDate(rs.getString(4));
th.setClickSum(rs.getInt(5));
th.setReplySum(rs.getInt(6));
th.setUserID(rs.getInt(7));
th.setDeep(rs.getInt(8));
ar.add(th);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
rs.close();
pt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return ar;
}
public ArrayList<threadBean> getthreadByID(int threadID){
ArrayList<threadBean> ar=new ArrayList<threadBean>();
PreparedStatement pt=null;
ResultSet rs=null;
Connection con=conn.getInstance();
try {
pt=con.prepareStatement("select * from BBSthread where threadID=?");
pt.setInt(1, threadID);
rs=pt.executeQuery();
while(rs.next()){
threadBean th=new threadBean();
th.setThreadID(rs.getInt(1));
th.setForumName(rs.getString(2));
th.setClickDate(rs.getString(3));
th.setCreateDate(rs.getString(4));
th.setClickSum(rs.getInt(5));
th.setReplySum(rs.getInt(6));
th.setUserID(rs.getInt(7));
th.setDeep(rs.getInt(8));
ar.add(th);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
rs.close();
pt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return ar;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -