JSP房地产网站

  • u2_259629
    了解作者
  • 2.7MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-12 01:44
    上传日期
jsp t 房地产网站 使用JSP作为开发语言,后台使用SQL SERVER作为数据库管理系统,开发环境是MyEclipse,服务器采用tomcat
房地产网站struts版本.rar
内容介绍
package bean; import java.sql.*; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; public class AdminBean { Connection conn = null; Statement st = null; Statement st1 = null; ResultSet rs = null; ResultSet rs1 = null; boolean bool = false; /** * 添加新闻 * @param title * @param text * @return */ public boolean newsAdd(String title,String text){ try{ conn = DBConn.getConn(); st=conn.createStatement(); st.executeUpdate("insert into T_NEWS values('"+getNUM()+"','"+title+"','"+text+"','"+getDate()+"',0,0)"); bool=true; }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return bool; } /** * 返回新闻全部内容 * @param title * @param text * @return */ public ArrayList news(){ ArrayList arr=new ArrayList(); try{ conn = DBConn.getConn(); st=conn.createStatement(); rs = st.executeQuery("select * from T_NEWS where CONTROL='0' order by LOGO desc"); while(rs.next()){ ArrayList col=new ArrayList(); col.add(rs.getString(1)); col.add(rs.getString(2)); col.add(rs.getString(3)); col.add(rs.getString(4)); col.add(rs.getString(5)); arr.add(col); } }catch(Exception e){ e.printStackTrace(); return null; }finally{ this.close(); } return arr; } /** * 得到一条新闻 * @return */ public ArrayList getnews(String no){ ArrayList col=new ArrayList(); try{ conn = DBConn.getConn(); st=conn.createStatement(); rs = st.executeQuery("select * from T_NEWS where NEWS_NUM='"+no+"' and CONTROL=0 "); if(rs.next()){ col.add(rs.getString(1)); col.add(rs.getString(2)); col.add(rs.getString(3)); col.add(rs.getString(4)); } }catch(Exception e){ e.printStackTrace(); return null; }finally{ this.close(); } return col; } /** * 修改新闻 * @param title * @param text * @return */ public boolean newsEdit(String title,String text,String no){ try{ conn = DBConn.getConn(); st=conn.createStatement(); st.executeUpdate("update T_NEWS set NEWS_TITLE='"+title+"', NEWS_TEXT='"+text+"',NEWS_TIME='"+getDate()+"' where NEWS_NUM='"+no+"'"); bool=true; }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return bool; } /** * 删除一条新闻 * @param no * @return */ public boolean newsDel(String no){ try{ conn = DBConn.getConn(); st=conn.createStatement(); st.executeUpdate("update T_NEWS set CONTROL=1 where NEWS_NUM='"+no+"'"); bool=true; }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return bool; } /** * 新闻查询 * @param sql * @return */ public ArrayList newsSearch(String sql){ ArrayList arr=new ArrayList(); ArrayList col=null; try{ conn = DBConn.getConn(); st=conn.createStatement(); rs=st.executeQuery(sql); while(rs.next()){ col=new ArrayList(); col.add(rs.getString(2)); col.add(rs.getString(3)); col.add(rs.getString(4)); arr.add(col); } }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return arr; } /** * 注册用户列表 * @return */ public ArrayList user(){ ArrayList arr=new ArrayList(); ArrayList col=null; try{ conn = DBConn.getConn(); st=conn.createStatement(); rs = st.executeQuery("select * from t_user where CONTROL=0 and USER_ID not in(1) ");//USER_ID为1的不能删 while(rs.next()){ col=new ArrayList(); col.add(rs.getString(1)); col.add(rs.getString(3)); col.add(rs.getString(4)); col.add(rs.getString(5)); col.add(rs.getString(6)); arr.add(col); } }catch(Exception e){ e.printStackTrace(); return null; }finally{ this.close(); } return arr; } /** * 得到用户信息 * @param no * @return */ public ArrayList getuser(String no){ ArrayList col=new ArrayList(); try{ conn = DBConn.getConn(); st=conn.createStatement(); rs = st.executeQuery("select * from T_USER where USER_NUM='"+no+"' and CONTROL=0 "); if(rs.next()){ col.add(rs.getString(1)); col.add(rs.getString(3)); col.add(rs.getString(4)); col.add(rs.getString(5)); col.add(rs.getString(6)); } }catch(Exception e){ e.printStackTrace(); return null; }finally{ this.close(); } return col; } /** * 修改用户信息 * @param name * @param pwd * @param age * @param email * @param no * @return */ public boolean userEdit(String name,String pwd,String age,String email,String no){ try{ conn = DBConn.getConn(); st=conn.createStatement(); st.executeUpdate("update T_USER set USER_NAME='"+name+"', USER_PWD='"+pwd+"',USER_AGE='"+age+"',USER_EMAIL='"+email+"' where USER_NUM='"+no+"'"); bool=true; }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return bool; } /** * 删除用户信息 * @param no * @return */ public boolean userDel(String no){ try{ conn = DBConn.getConn(); st=conn.createStatement(); st.executeUpdate("update T_USER set CONTROL=1 where USER_NUM='"+no+"'"); bool=true; }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return bool; } public boolean firstNewsEdit(String no){ try{ conn = DBConn.getConn(); st=conn.createStatement(); st.executeUpdate("update T_NEWS set LOGO=0 where CONTROL=0");//先全部变成0 st1=conn.createStatement(); st1.executeUpdate("update T_NEWS set LOGO=1 where NEWS_NUM='"+no+"'");//再将设置的这条记录变成1 bool=true; }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return bool; } /** * 求租列表 * @return */ public ArrayList buy1(){ ArrayList arr=new ArrayList(); ArrayList col=null; try{ conn = DBConn.getConn(); st=conn.createStatement(); rs = st.executeQuery("select * from T_BUY where CONTROL=0 and BUY_FLAG=1"); while(rs.next()){ col=new ArrayList(); col.add(rs.getString(1)); col.add(rs.getString(2)); col.add(rs.getString(3)); col.add(rs.getString(4)); col.add(rs.getString(5)); col.add(rs.getString(6)); col.add(rs.getString(7)); arr.add(col); } }catch(Exception e){ e.printStackTrace(); return null; }finally{ this.close(); } return arr; } /** * 添加求租信息到数据库 * @param area * @param struct * @param price * @param time * @param man * @param phone * @return */ public boolean buy1Add(String area,String struct,String price,String time,String man,String phone){ try{ conn = DBConn.getConn(); st=conn.createStatement(); st.executeUpdate("insert into T_BUY values('"+getNUM()+"','"+area+"','"+struct+"','"+price+"','"+time+"','"+man+"','"+phone+"',1,0)"); bool=true; }catch(Exception e){ e.printStackTrace(); bool=false; }finally{ this.close(); } return bool; } /** * 得到求租信息 * @param no
评论
    相关推荐