📄 topicdao.java
字号:
/*******************************************************************\* ** LightningBoard ** ** http://sourceforge.net/projects/lightningboard/ ** ** Copyright (c) 2002 Xiaobo Liu ** *********************************************************************** LICENSE INFORMATION ** ** LightningBoard is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as ** published by the Free Software Foundation; either version 2 of ** the License, or any later version. ** ** We don't charge anything for the use of LightningBoard, we only ** require you to keep the copyright present on your site and in ** the source files. ** ** LightningBoard is distributed in the hope that it will be useful,** but without any warranty; without even the implied warranty of ** merchantability or fitness for a particular purpose. See the GNU ** General Public License for more details. ** *\*******************************************************************/package liuxiaobo.lb.dao;import java.sql.*;import java.util.*;import liuxiaobo.db.*;import liuxiaobo.lb.*;import liuxiaobo.lb.bean.*;public class TopicDAO { private DBConnectionManager dbcm = DBConnectionManager.getInstance(); public TopicBean execute(int t_id)throws ActionException{ Connection connection=null; try { TopicBean topicBean=new TopicBean(); connection=dbcm.getConnection(); DBAccess dba=new DBAccess(connection); String sql="SELECT t_f_id,f_name,f_info,f_u_id,u_name,f_topics,f_messages,t_name,t_replies,t_views FROM forum,topic,user WHERE t_f_id=f_id AND f_u_id=u_id AND t_id=" + t_id; ResultSet rs=dba.openSelect(sql); //check result if (!rs.next()) return null; rs.beforeFirst(); while (rs.next()){ topicBean.setF_id(rs.getString("t_f_id")); topicBean.setF_name(rs.getString("f_name")); topicBean.setF_info(rs.getString("f_info")); topicBean.setF_u_id(rs.getString("f_u_id")); topicBean.setU_name(rs.getString("u_name")); topicBean.setF_topics(rs.getString("f_topics")); topicBean.setF_messages(rs.getString("f_messages")); topicBean.setT_id(String.valueOf(t_id)); topicBean.setT_name(rs.getString("t_name")); topicBean.setT_replies(rs.getString("t_replies")); topicBean.setT_views(rs.getString("t_views")); } rs.close(); dba.closeSelect(); //------------------------ sql="SELECT m_id,m_content,m_time,m_u_id,u_name,u_regtime,u_address,u_post,u_sign FROM message,user WHERE m_u_id=u_id AND m_t_id=" + t_id + " ORDER BY m_time"; rs = dba.openSelect(sql); //check result if (!rs.next()) return null; rs.beforeFirst(); List messageList=new LinkedList(); while(rs.next()){ Message message=new Message(); message.setM_id(rs.getString("m_id")); message.setM_content(rs.getString("m_content")); message.setM_time(rs.getString("m_time")); message.setM_u_id(rs.getString("m_u_id")); message.setU_name(rs.getString("u_name")); message.setU_regtime(rs.getString("u_regtime")); message.setU_address(rs.getString("u_address")); message.setU_post(rs.getString("u_post")); message.setU_sign(rs.getString("u_sign")); messageList.add(message); } topicBean.setMessages(messageList); rs.close(); dba.closeSelect(); //view dba.runSql("UPDATE topic SET t_views=t_views+1 WHERE t_id="+t_id); //jump CommonDAO commonDAO=new CommonDAO(); topicBean.setForumMap(commonDAO.getForumMap(dba)); return topicBean; } catch (Exception ex) { throw new ActionException(ex); }finally{ try { dbcm.freeConnection(connection); } catch (SQLException ex) { // } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -