package com;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import db.DB;
public class UserInfo {
private static final long serialVersionUID = 1L;
private int userid;
private String userName;
private String password;
private String gender;
private String address;
private int type;
public UserInfo() {
super();
}
public UserInfo(int userid, String userName, String password,
String gender, String address, int type) {
super();
this.userid = userid;
this.userName = userName;
this.password = password;
this.gender = gender;
this.address = address;
this.type = type;
}
/**
* @return the userid
*/
public int getUserid() {
return userid;
}
/**
* @param userid
* the userid to set
*/
public void setUserid(int userid) {
this.userid = userid;
}
/**
* @return the userName
*/
public String getUserName() {
return userName;
}
/**
* @param userName
* the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password
* the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @param gender
* the gender to set
*/
public void setGender(String gender) {
this.gender = gender;
}
/**
* @return the gender
*/
public String getGender() {
return gender;
}
/**
* @return the address
*/
public String getAddress() {
return address;
}
/**
* @param address
* the address to set
*/
public void setAddress(String address) {
this.address = address;
}
/**
* @return the type
*/
public int getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(int type) {
this.type = type;
}
/**
* @return the serialversionuid
*/
public static long getSerialversionuid() {
return serialVersionUID;
}
public ArrayList<UserInfo> findAll() throws SQLException,
ClassNotFoundException {
Connection conn = new DB().getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from UserInfo");
ArrayList<UserInfo> list = new ArrayList<UserInfo>();
while (rs.next()) {
// System.out.println("ID: " + rs.getInt(1) + " 用户名:"
// + rs.getString(2) + " 密码:" + rs.getString(3) + " 性别:"
// + rs.getString(4) + " 地址:" + rs.getString(5));
UserInfo uinfo = new UserInfo(rs.getInt(1), rs.getString(2),
rs.getString(3), rs.getString(4), rs.getString(5), rs.getInt(6));
list.add(uinfo);
}
rs.close();
stmt.close();
conn.close();
return list;
}
public UserInfo findbyId(Long id) throws ClassNotFoundException,
SQLException {
UserInfo uinfo = null;
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("select * from UserInfo where userId=?");
pStmt.setLong(1, id);
ResultSet rs = pStmt.executeQuery();
if (rs.next()) {
// System.out.println("ID: " + rs.getInt(1) + " 用户名:"
// + rs.getString(2) + " 密码:" + rs.getString(3) + " 性别:"
// + rs.getString(4) + " 地址:" + rs.getString(5));
uinfo = new UserInfo(rs.getInt(1), rs.getString(2),
rs.getString(3), rs.getString(4), rs.getString(5), rs.getInt(6));
}
rs.close();
pStmt.close();
conn.close();
return uinfo;
}
public UserInfo findbyName(String username) throws ClassNotFoundException,
SQLException {
UserInfo uinfo = null;
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("select * from UserInfo where userName=?");
pStmt.setString(1, username);
ResultSet rs = pStmt.executeQuery();
if (rs.next()) {
// System.out.println("ID: " + rs.getInt(1) + " 用户名:"+
// rs.getString(2) + " 密码:" + rs.getString(3) + " 性别:"+
// rs.getString(4) + " 地址:" + rs.getString(5) + "用户类型" + rs.getInt(6));
uinfo = new UserInfo(rs.getInt(1), rs.getString(2),
rs.getString(3), rs.getString(4), rs.getString(5), rs.getInt(6));
}
rs.close();
pStmt.close();
conn.close();
return uinfo;
}
public boolean checkNameExist(String name) throws ClassNotFoundException,
SQLException {
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("select * from UserInfo where userName=?");
pStmt.setString(1, name);
ResultSet rs = pStmt.executeQuery();
if (rs.next()) {
rs.close();
pStmt.close();
conn.close();
return true;
} else {
rs.close();
pStmt.close();
conn.close();
return false;
}
}
public int delById(int id) throws ClassNotFoundException, SQLException {
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("delete from UserInfo where userId=?");
pStmt.setInt(1, id);
int result = pStmt.executeUpdate();
pStmt.close();
conn.close();
return result;
}
public int upgradeById(int id) throws ClassNotFoundException, SQLException {
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("update UserInfo set type=2 where userId=?");
pStmt.setInt(1, id);
int result = pStmt.executeUpdate();
pStmt.close();
conn.close();
return result;
}
public void register() throws ClassNotFoundException, SQLException {
try {
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("insert into UserInfo (userName,password,gender,address,type) values(?,?,?,?,?)");
pStmt.setString(1, getUserName());
pStmt.setString(2, getPassword());
pStmt.setString(3, getGender());
pStmt.setString(4, getAddress());
pStmt.setInt(5, getType());
System.out.println(getUserName());
int n = pStmt.executeUpdate();
pStmt.close();
conn.close();
// if (n == 1) {
// return true;
// } else {
// return false;
// }
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public boolean login() throws ClassNotFoundException, SQLException {
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("select * from UserInfo where userName=? and password=?");
pStmt.setString(1, getUserName());
pStmt.setString(2, getPassword());
ResultSet rs = (ResultSet) pStmt.executeQuery();
if (rs.next()) {
rs.close();
pStmt.close();
return false;
}
conn.close();
return true;
}
public int update(Long id, String pwd) throws ClassNotFoundException,
SQLException {
Connection conn = new DB().getConnection();
PreparedStatement pStmt = conn
.prepareStatement("update UserInfo set password=? where userId=?");
pStmt.setString(1, pwd);
pStmt.setLong(2, id);
int n = pStmt.executeUpdate();
pStmt.close();
conn.close();
return n;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
基于JSP的在线调查问卷系统.zip (213个子文件)
bootstrap.min.css 103KB
bootstrap-responsive.min.css 16KB
wc.db 99KB
JSP综合性实验报告.doc 285KB
entries 3B
format 3B
mysql-connector-java-5.1.24-bin.jar 826KB
UserInfo.java 7KB
LogoutListener.java 6KB
PaperDaoImpl.java 5KB
AddPaper.java 3KB
SurveySubmit.java 3KB
PaperServiceImpl.java 3KB
QuestionDaoImpl.java 3KB
LoginServlet.java 3KB
RegisterServlet.java 3KB
QuestionServlet.java 3KB
AdminServlet.java 3KB
LoginInfo.java 3KB
Paper.java 3KB
BaseDao.java 2KB
LoginFilter.java 2KB
SurveyPage.java 2KB
ShowResult.java 2KB
Question.java 1KB
QuestionServiceImpl.java 1KB
DB.java 616B
PaperService.java 489B
PaperDao.java 478B
QuestionDao.java 433B
QuestionService.java 197B
jquery.js 90KB
bootstrap.js 60KB
bootstrap.min.js 28KB
html5shiv.js 2KB
showresult.jsp 6KB
showResultAfterAnswer.jsp 6KB
userManagement.jsp 4KB
main.jsp 3KB
surveypage.jsp 3KB
preScanSurvey.jsp 3KB
addChoiceQuestion.jsp 3KB
addMultiChoiceQt.jsp 3KB
addpaper.jsp 2KB
adduser.jsp 2KB
register.jsp 2KB
addAnswerQuestion.jsp 2KB
login.jsp 2KB
MysqlTest.jsp 1KB
showpaper.jsp 1010B
addQuestionSuccess.jsp 955B
temp.jsp 805B
MANIFEST.MF 36B
glyphicons-halflings.png 12KB
glyphicons-halflings-white.png 9KB
Config.properties 210B
jdbc.sql 7KB
6a1171c774eb606e4d878d2703ceb16ea90edaa9.svn-base 984KB
d679fc9511f1ec41d3265ee4c02322cc2d2d2218.svn-base 964KB
a7d599d73b86a928303909b9be7573a4ea0ed28e.svn-base 826KB
cd8e36d996d5b2ccad7e368357bacc598912331f.svn-base 288KB
49030196018e6a8cc401b3c88b2d48e533f3e8bb.svn-base 190KB
477a15bedfc71b900f7b623725fc2693e6304aab.svn-base 124KB
1abefd404cdd720b275cdafb97d3ee1c87fd97ef.svn-base 103KB
a1ce0bfa507f23cc414a9a7634bd73b994bb3b35.svn-base 90KB
982a75004c32b52bfadb0d296867780dba232543.svn-base 60KB
81354dcfc6d99a1a43678dd9719d0d279271a02e.svn-base 28KB
b87c9af4988d92bcfba4ce80f1bbf267774e115f.svn-base 22KB
fee31889cf7e7b1531bf61d8109be2a6007853d6.svn-base 16KB
84f613631b07d4fe22acbab50e551c0fe04bd78b.svn-base 12KB
a25c4705320fd63c33790e666872910e702b9bf6.svn-base 9KB
f6056305afd74440b1fd5fc37d423dd97b16e38d.svn-base 7KB
95906dc34c8ca6129dda60da23ad7ceee7c76f78.svn-base 7KB
7b8e2ab5cbedd69c8921e7bd89f1cd80202d00c9.svn-base 7KB
a0b6f5caacec059800c91b60443f7dd30b157dd7.svn-base 6KB
fcfb2715c0cf7bf26c82f202628bd7ce20119c81.svn-base 6KB
3201845fe66b8480883d3a22790ef2d5e7cd9459.svn-base 6KB
77d48c7f45d79efdf29c14ed2a0bbc016ec6adcd.svn-base 6KB
6601dd16dcf3a9522c3d512b4c61d2f02cc9aba3.svn-base 6KB
fb93f081a68b5abc5b5f55f4dc2879ce07a30cb3.svn-base 6KB
b97b4ea41568810a6eeaf4fcc559eb703b730e3f.svn-base 6KB
220ddfb05f41d875a1ec1c3140854bc5c3aa640a.svn-base 6KB
a36cfc73e93f2488753d62fcef0b3cacb81a1a33.svn-base 6KB
996867caf79a93609b090f474d4458b167fea45b.svn-base 5KB
3f8273a7d96cd0f8f9ab3f2817dd8e1e84d25b14.svn-base 5KB
f37d255d7ac577d428ce6a4e227e9558f3c8568a.svn-base 5KB
32859f38fdca0c79a9994391e2b371b42b078945.svn-base 5KB
8aa844e22c79c4666fe00c9c8fb2d026d94e8097.svn-base 4KB
cc456d2e3865dd1f6277d7270548ec3e1f6f5781.svn-base 4KB
4cfd4102a9cbb1c2245c5c3a20ca97af29ff38a0.svn-base 4KB
200b9daa3377b3fec70a6696cd4ac3cd287c163e.svn-base 4KB
c71e7a5e23e576c41f48d07d302f09e142a4b300.svn-base 4KB
306821d4201dab269ffb13c55bcd6bfe4de1c5ca.svn-base 4KB
0dff064585635fdba246cc26648aa2dcc06f13ea.svn-base 4KB
b007f98820e3942c0da6de43d321e62a20f76e2d.svn-base 4KB
d1f0e331b7057261ebc67ad5f455491019e40e0e.svn-base 4KB
4b34f60250c3161e7200ec0a20764b565d552ccf.svn-base 4KB
6736670333e07a551b910b7c871218203ba1fa20.svn-base 4KB
eba99ff85cbed4a52a38a6bdb9fdc3a066e6ed04.svn-base 3KB
05bd2488e9f9e39dfc673ba12cb9deb8c04d455d.svn-base 3KB
共 213 条
- 1
- 2
- 3
菜鸟的学习历程
- 粉丝: 27
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 电力场景设备漏油检测数据集VOC+YOLO格式338张1类别.7z
- 基于yolov8+pyqt5实现精美界面支持图片视频和摄像检测源码.zip
- 用C语言为母亲节献上一份特别的祝福.zip
- LCD1602液晶显示屏的深入探索与实用指南.zip
- 基于Matlab人脸肤色定理的教师人数统计+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab霍夫曼变换的表盘读数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab火灾烟雾检测源码带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的恶劣天气交通标志识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的霍夫曼变换的表盘示数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的车道线识别系统 +源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0