⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 homedao.java

📁 用java实现的一个论坛,可以供大家参考
💻 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 HomeDAO  {  private DBConnectionManager dbcm = DBConnectionManager.getInstance();  public HomeBean execute() throws ActionException{    Connection connection=null;    try {      HomeBean homeBean=new HomeBean();      connection=dbcm.getConnection();      DBAccess dba=new DBAccess(connection);      String sql="SELECT f_id,f_name,f_info,f_u_id,user1.u_name as u_name,f_topics,f_messages,f_u_id2,user2.u_name as u_name2,f_lasttime FROM forum,user user1 ,user user2 WHERE forum.f_u_id=user1.u_id AND forum.f_u_id2=user2.u_id ORDER BY f_order";      ResultSet rs=dba.openSelect(sql);//check result      if (!rs.next())        return null;      rs.beforeFirst();      LinkedList forums=new LinkedList();      while(rs.next()){        Forum forum=new Forum();        forum.setF_id(rs.getString("f_id"));        forum.setF_name(rs.getString("f_name"));        forum.setF_info(rs.getString("f_info"));        forum.setF_u_id(rs.getString("f_u_id"));        forum.setU_name(rs.getString("u_name"));        forum.setF_topics(rs.getString("f_topics"));        forum.setF_messages(rs.getString("f_messages"));        forum.setF_u_id2(rs.getString("f_u_id2"));        forum.setU_name2(rs.getString("u_name2"));        forum.setF_lasttime(rs.getString("f_lasttime"));        forums.add(forum);      }      homeBean.setForums(forums);      rs.close();      dba.closeSelect();      //topicsSum      rs=dba.openSelect("select count(*) as cnt from topic");      if (rs.next()){        homeBean.setTopicSum(rs.getString(1));      }      rs.close();      dba.closeSelect();      //messagesSum      rs=dba.openSelect("select count(*) as cnt from message");      if (rs.next()){        homeBean.setMessageSum(rs.getString(1));      }      rs.close();      dba.closeSelect();      //usersSum      rs=dba.openSelect("select count(*) as cnt from user");      if (rs.next()){        homeBean.setUserSum(rs.getString(1));      }      rs.close();      dba.closeSelect();      return homeBean;    } 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 + -