package com.dao;
import java.sql.*;
import java.util.Collection;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import com.core.Database;
import com.core.FinalConstants;
import com.core.ParamUtils;
import com.model.User;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: MR</p>
* @author BWM
* @version 1.0
*/
public class Dbuser extends User {
private User u = new User();
//不使初始化select
public Dbuser(){}
//使用数据库始化update
public Dbuser(String sql) {
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = Database.getConnection();
ps = con.prepareStatement(FinalConstants.SELECT_USER+sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = ps.executeQuery();
if (rs.next()) {
u.setUid(ParamUtils.getSqlString(rs.getString("uid")));
u.setPassword(ParamUtils.getSqlString(rs.getString("password")));
u.setName(ParamUtils.getSqlString(rs.getString("name")));
u.setRegqu(ParamUtils.getSqlString(rs.getString("regqu")));
u.setReganswer(ParamUtils.getSqlString(rs.getString("reganswer")));
u.setIid(ParamUtils.getSqlString(rs.getString("iid")));
u.setSex(rs.getInt("sex"));
u.setAge(rs.getInt("age"));
u.setTel(ParamUtils.getSqlString(rs.getString("tel")));
u.setEmail(ParamUtils.getSqlString(rs.getString("email")));
u.setQq(ParamUtils.getSqlString(rs.getString("qq")));
u.setRegtime(ParamUtils.getSqlString(rs.getString("regtime")));
u.setAddress(ParamUtils.getSqlString(rs.getString("address")));
u.setHttp(ParamUtils.getSqlString(rs.getString("http")));
u.setStatus(rs.getInt("status"));
u.setState(rs.getInt("state"));
u.setResume(ParamUtils.getSqlString(rs.getString("resume")));
}
} catch (SQLException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} finally {
System.out.println(ps+" Dbuser(String sql) "+u.getUid());
try {
if (ps != null) {
ps.close();
ps = null;
}
} catch (SQLException e) {
ps = null;
}
try {
if (con != null) {
con.close();
con = null;
}
} catch (SQLException e) {
con = null;
}
}
}
//使用内建对像初始化insert
public Dbuser(HttpServletRequest request) {
u.setUid(ParamUtils.getRequestString(request, "uid"));
u.setPassword(ParamUtils.getRequestString(request, "password"));
u.setName(ParamUtils.getRequestString(request, "name"));
u.setRegqu(ParamUtils.getRequestString(request, "regqu"));
u.setReganswer(ParamUtils.getRequestString(request, "reganswer"));
u.setSex(ParamUtils.getIntParameter(request, "sex"));
u.setAge(ParamUtils.getIntParameter(request, "age"));
u.setIid(ParamUtils.getRequestString(request, "iid"));
u.setTel(ParamUtils.getRequestString(request, "tel"));
u.setEmail(ParamUtils.getRequestString(request, "email"));
u.setQq(ParamUtils.getRequestString(request, "qq"));
u.setAddress(ParamUtils.getRequestString(request, "address"));
u.setHttp(ParamUtils.getRequestString(request, "http"));
u.setStatus(ParamUtils.getIntParameter(request, "status"));
u.setState(ParamUtils.getIntParameter(request, "state"));
u.setResume(ParamUtils.getRequestString(request, "resume"));
}
//注册时间插入系统时间
public boolean Insert() {
boolean b = false;
Connection con = null;
PreparedStatement ps = null;
try {
con = Database.getConnection();
ps = con.prepareStatement(FinalConstants.INSERT_USER);
System.out.println("Dbuser.java中:"+FinalConstants.INSERT_USER+"结束");
ps.setString(1, u.getUid());
ps.setString(2, u.getPassword());
ps.setString(3, u.getName());
ps.setString(4, u.getRegqu());
ps.setString(5, u.getReganswer());
ps.setString(6, u.getIid());
ps.setInt(7, u.getSex());
ps.setInt(8, u.getAge());
ps.setString(9, u.getTel());
ps.setString(10, u.getEmail());
ps.setString(11, u.getQq());
ps.setString(12, u.getAddress());
ps.setString(13, u.getHttp());
ps.setInt(14, u.getStatus());
ps.setInt(15, u.getState());
ps.setString(16, u.getResume());
if (ps.executeUpdate() > 0) {
b = true;
} else {
b = false;
}
} catch (SQLException e) {
b = false;
System.out.println(e.getMessage());
e.printStackTrace();
} finally {
System.out.println(ps+" Dbuser.Insert()");
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {
ps = null;
}
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
con = null;
}
}
return b;
}
private boolean Update() {
boolean b = false;
Connection con = null;
PreparedStatement ps = null;
try {
con = Database.getConnection();
ps = con.prepareStatement(FinalConstants.UPDATE_USER);
ps.setString(1, u.getPassword());
ps.setString(2, u.getName());
ps.setString(3, u.getIid());
ps.setInt(4, u.getSex());
ps.setInt(5, u.getAge());
ps.setString(6, u.getTel());
ps.setString(7, u.getEmail());
ps.setString(8, u.getQq());
ps.setString(9, u.getAddress());
ps.setString(10, u.getHttp());
ps.setInt(11, u.getStatus());
ps.setInt(12, u.getState());
ps.setString(13, u.getResume());
ps.setString(14, u.getUid());
if (ps.executeUpdate() > 0) {
b = true;
} else {
b = false;
}
} catch (SQLException e) {
b = false;
e.printStackTrace();
} finally {
System.out.println(ps+" Dbuser.Update() ");
try {
if (ps != null) {
ps.close();
}
} catch (SQLException e) {
ps = null;
}
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
con = null;
}
}
return b;
}
private boolean Update_m() {
boolean b = false;
Connection con = null;
PreparedStatement ps = null;
try {
con = Database.getConnection();
ps = con.prepareStatement(FinalConstants.UPDATE_USER_M);
ps.setInt(1, u.getStatus());
ps.setInt(2, u.getState());
ps.setString(3, u.getUid());
if (ps.executeUpdate() > 0) {
b = true;
} else {
b = false;
}
} catch (SQLException e) {
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目源码】java企业门户网站项目 配置源程序 MySQL数据库 (1)运行MySQL目录下MySQL Server Instance Config Wizard,配置数据库编码格式,把数据库的编码格式改为默认编码格式; 将MR\14\WebRoot\Database文件夹中的扩展名为14.sql的文件拷贝到本地机器中。 (2)打开MySQL的“MySQL Administrator”,并登录(本系统需要使用root和111登录),然后单击restore节点,在右侧单击“Open backup File”按钮,在弹出的对话框中,选择14.sql文件,并单击“打开”按钮。 (3)单击“Open Restore”按钮,即可完成数据库的附加操作。 将程序导入到MyEclipse中,并发布运行 (1)将“MR\14\”文件夹拷贝到MyEclipse的工作空间中。
资源推荐
资源详情
资源评论
收起资源包目录
项目源码java企业门户网站项目 (244个子文件)
Dbuser.class 13KB
Dbsoft.class 12KB
Dbmend.class 10KB
Dbresolvent.class 9KB
Dbguestboard.class 8KB
DbBasetableFactory.class 8KB
Dbaffiche.class 8KB
Dblink.class 7KB
Dbquestion.class 7KB
Dbnew.class 7KB
Dbssort.class 7KB
BasetableFactoryProxy.class 7KB
Dbhead.class 7KB
FinalConstants.class 5KB
Database.class 4KB
User.class 3KB
Soft.class 3KB
StringUtils.class 3KB
ParamUtils.class 3KB
BasetableFactory.class 3KB
HtmlUtils.class 2KB
Mend.class 2KB
Line.class 2KB
SetCharacterEncodingFilter.class 2KB
Guestboard.class 2KB
Resolvent.class 2KB
Fsort.class 2KB
FileUtils.class 2KB
New.class 1KB
Affiche.class 1KB
Head.class 1KB
Crazyadept.class 1KB
Link.class 1KB
Question.class 919B
Ssort.class 917B
.classpath 510B
org.eclipse.wst.jsdt.ui.superType.container 49B
css.css 7KB
style.css 1KB
admin.css 1KB
Thumbs.db 141KB
Thumbs.db 134KB
Thumbs.db 41KB
Thumbs.db 27KB
程序使用说明.doc 113KB
admin_top1.gif 114KB
admin_top.gif 78KB
download.gif 22KB
blank_bg.gif 7KB
picture_newsNotice.gif 5KB
logo.gif 4KB
ashline_foot.gif 4KB
left_title_gjbdxzph.GIF 4KB
left_title_rjxzph.GIF 4KB
left_title_wzgg.GIF 3KB
left_title_yqlj.GIF 3KB
index_type.gif 3KB
select.gif 3KB
bullion.gif 3KB
title_newsNotice.gif 3KB
08.gif 3KB
01.gif 3KB
index_07.gif 3KB
bg.GIF 2KB
admin_bar.gif 2KB
download.gif 2KB
title_introduce.GIF 1KB
222_13.gif 1KB
222_22.gif 1KB
email.gif 1KB
bg_ad.GIF 1KB
vip.gif 993B
male.gif 938B
del.gif 835B
admin_bg.gif 717B
reply.gif 710B
close.gif 697B
home.gif 645B
exit.gif 641B
submit.gif 640B
222_10.gif 553B
222_30.gif 544B
icon.gif 538B
modify.gif 509B
search.gif 452B
announce.gif 428B
arrow.gif 290B
star.gif 288B
admin_ico.gif 270B
more.gif 255B
bg_navigation.GIF 255B
index_02.gif 246B
index_10.gif 189B
banner_bg.gif 184B
top_about.gif 177B
ashline_head.gif 167B
whiteline_head.gif 126B
top_contact.GIF 82B
top_homepage.GIF 70B
top_favorite.GIF 69B
共 244 条
- 1
- 2
- 3
资源评论
西攻城狮北
- 粉丝: 8416
- 资源: 434
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功