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

📄 information.java

📁 JAVA+JSP程序系统-华源网络科技论坛
💻 JAVA
字号:
package org.jetic.web.techbbs;import java.sql.ResultSet;import javax.servlet.http.HttpSession;/** * Title:        华源技术论坛 * Description: * Copyright:    Copyright (c) 2001 * Company:      GBSOURCE * @author fainter * @version 1.0 */public class Information {    private Mssql conn;    private ResultSet rs;    private int page = 1;    private int pagesize = 20;    private int pagecount = 0;    private int TopiclistPageCount = 0;    private int boardID = 1;    private String title="";    private String writer="";    private String content="";    public int getPage() {        if (page < 1)   page = 1;        if (page > TopiclistPageCount)  page = TopiclistPageCount;        return page;    }    public void setPage(int newPage) {        page = newPage;    }    public void setPagesize(int newPagesize) {        pagesize = newPagesize;    }    public int getPagesize() {        return pagesize;    }    public void setPagecount(int newPagecount) {        pagecount = newPagecount;    }    public int getPagecount() {        return pagecount;    }    public void setboardID(int newboardID) {        boardID = newboardID;    }    public int getboardID() {        return boardID;    }    public void settitle(String newtitle) {        title = newtitle;    }    public String gettitle() {        return title;    }    public void setwriter(String newwriter) {        writer = newwriter;    }    public String getwriter() {        return writer;    }    public void setcontent(String newcontent) {        content = newcontent;    }    public String getcontent() {        return content;    }    public String getTopiclistInfo() {         String TopiclistInfo="";         try {            conn = new Mssql();            conn.prepareStatement("select count(*) from tbtopic where fdimain=? and fditopic=0");                conn.setInt(1, boardID);                rs = conn.executeQuery();            if (rs.next()) {                TopiclistPageCount = (rs.getInt(1) - 1) / pagesize + 1;            }            rs.close();            conn.close();        }        catch (Exception ex) {            ex.printStackTrace(System.err);        }        for(int i=1;i<=TopiclistPageCount;i++) {            if (i==page) TopiclistInfo = TopiclistInfo + i + " ";            else TopiclistInfo = TopiclistInfo + "<a href='Topic.jsp?boardID=" + boardID + "&page=" + i + "'>" + i + "</a> ";        }        return TopiclistInfo;    }    public String getMarklistInfo() {         String MarklistInfo="";         try {            conn = new Mssql();            conn.prepareStatement("select count(*) from tbtopic where fdimain=? and fdcmark='M'");                conn.setInt(1, boardID);                rs = conn.executeQuery();            if (rs.next()) {                TopiclistPageCount = (rs.getInt(1) - 1) / pagesize + 1;            }            rs.close();            conn.close();        }        catch (Exception ex) {            ex.printStackTrace(System.err);        }        for(int i=1;i<=TopiclistPageCount;i++) {            if (i==page) MarklistInfo = MarklistInfo + i + " ";            else MarklistInfo = MarklistInfo + "<a href='marked.jsp?boardID=" + boardID + "&page=" + i + "'>" + i + "</a> ";        }        return MarklistInfo;    }    public int TopiclistPageCount() {        return this.TopiclistPageCount;    }  public String userinfo(String name){       String userinfo=name;         try {           int post;            conn = new Mssql();            rs = conn.executeQuery("select fdipost from users where userid ='" + name + "'");           while (rs.next()) {            post = rs.getInt("fdipost");            if(post>=0 && post<30)                 userinfo = userinfo + " (新手上路)<br>发表文章:" + post;            else if(post>=30 && post<60)                 userinfo = userinfo + " (一般战友)<br>发表文章:" + post;            else if(post>=60 && post<90)                 userinfo = userinfo + " (中级战友)<br>发表文章:" + post;            else if(post>=90 && post<120)                 userinfo = userinfo + " (高级战友)<br>发表文章:" + post;            else if(post>=120)                 userinfo = userinfo + " (开国元老)<br>发表文章:" + post;            }            rs.close();            conn.close();        }    catch (Exception ex) {            System.err.println("error");            ex.printStackTrace(System.err);        }    return userinfo;  }  public String boardname(int boardID){       String boardname="";         try {            conn = new Mssql();            rs = conn.executeQuery("select fdcname from tbmain where id =" + boardID);           while (rs.next()) {            boardname = rs.getString("fdcname");            }            rs.close();            conn.close();        }    catch (Exception ex) {            System.err.println("error");            ex.printStackTrace(System.err);        }           return boardname;  }  public void online(String IP,HttpSession session, String act){        String userid = (String) session.getValue("userid");              if(userid == null || userid.equals(""))                  userid = "Guest";              try {            conn = new Mssql();            rs = conn.executeQuery("select id from tbonline where fdcip='" + IP +"'");            if(rs.next())            conn.executeUpdate("update tbonline set userid='" + userid + "', fdcact='" + act + "',fdtime=getdate() where fdcip='" + IP + "'");            else            conn.executeUpdate("insert into tbonline(userid,fdcip,fdcact) values('" + userid + "','" + IP + "','" + act + "')");            conn.close();              }              catch (Exception ex) {            System.err.println("error");            ex.printStackTrace(System.err);              }   }  public void click(int id) {    try {            Mssql mssql = new Mssql();            mssql.executeUpdate("update tbtopic set fdiclick=fdiclick+1 where id =" + id);        }    catch (Exception ex) {            System.err.println("error");            ex.printStackTrace(System.err);        }  }    public void logout(HttpSession session){        String userid = (String) session.getValue("userid");        if(userid == null || userid.equals(""))        return;        else    {       try {            conn = new Mssql();            conn.executeUpdate("delete from tbonline where userid='" + userid + "'");            conn.close();        }        catch (Exception ex) {            System.err.println("error");            ex.printStackTrace(System.err);       }       }   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -