package com.dao;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.common.SqlConn;
import com.model.Users;
public class UsersDAO {
private Connection conn;
public UsersDAO()
{
SqlConn sqlConn=new SqlConn();
conn=sqlConn.getConn();
}
//增加
public void add(Users users)
{
String sql="insert into users values(?,?,?,?,?,?,?,?,?,?,?,?)";
try {
PreparedStatement pState=conn.prepareStatement(sql);
pState.setString(1, users.getUser_id());
pState.setString(2, users.getUser_name());
pState.setString(3, users.getUser_sex());
pState.setDate(4, (Date) users.getUser_birthday());
pState.setString(5, users.getUser_minzu());
pState.setString(6, users.getUser_mianmao());
pState.setString(7, users.getUser_tell());
pState.setString(8, users.getUser_add());
pState.setString(9, users.getUser_email());
pState.setString(10, users.getUser_xueli());
pState.setString(11, users.getDep_Name());
pState.setString(12, users.getUser_beizu());
pState.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
//修改
public void edit(Users users)
{
String sql="update users set user_name=?,user_sex=?,user_birthday=?,user_minzu=?,user_mianmao=?,user_tell=?,user_add=?,user_email=?,user_xueli=?,dep_name=?,user_beizu=? where user_id=?";
try {
PreparedStatement pState=conn.prepareStatement(sql);
pState.setString(12, users.getUser_id());
pState.setString(1, users.getUser_name());
pState.setString(2, users.getUser_sex());
pState.setDate(3, (Date) users.getUser_birthday());
pState.setString(4, users.getUser_minzu());
pState.setString(5, users.getUser_mianmao());
pState.setString(6, users.getUser_tell());
pState.setString(7, users.getUser_add());
pState.setString(8, users.getUser_email());
pState.setString(9, users.getUser_xueli());
pState.setString(10, users.getDep_Name());
pState.setString(11, users.getUser_beizu());
pState.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
//删除
public void del(String usersId)
{
String sql="delete from users where user_id=?";
try {
PreparedStatement pState=conn.prepareStatement(sql);
pState.setString(1, usersId);
pState.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
//查询
public Users findById(String usersId)
{
String sql="select * from users where user_id like '%"+usersId+"%'";
Users users=new Users();
try {
Statement statement=conn.createStatement();
ResultSet rs=statement.executeQuery(sql);
if(rs.next())
{
users.setUser_id(rs.getString("user_id"));
users.setUser_name(rs.getString("user_name"));
users.setUser_sex(rs.getString("user_sex"));
users.setUser_birthday(rs.getDate("user_birthday"));
users.setUser_minzu(rs.getString("user_minzu"));
users.setUser_mianmao(rs.getString("user_mianmao"));
users.setUser_tell(rs.getString("user_tell"));
users.setUser_add(rs.getString("user_add"));
users.setUser_email(rs.getString("user_email"));
users.setUser_xueli(rs.getString("user_xueli"));
users.setDep_Name(rs.getString("dep_Name"));
users.setUser_beizu(rs.getString("user_beizu"));
}
} catch (Exception e) {
e.printStackTrace();
}
return users;
}
public List<Users> findAll()
{
String sql="select * from users";
List<Users> list=new ArrayList<Users>();
Users users=null;
try {
Statement statement=conn.createStatement();
ResultSet rs=statement.executeQuery(sql);
while(rs.next())
{
users=new Users();
users.setUser_id(rs.getString("user_id"));
users.setUser_name(rs.getString("user_name"));
users.setUser_sex(rs.getString("user_sex"));
users.setUser_birthday(rs.getDate("user_birthday"));
users.setUser_minzu(rs.getString("user_minzu"));
users.setUser_mianmao(rs.getString("user_mianmao"));
users.setUser_tell(rs.getString("user_tell"));
users.setUser_add(rs.getString("user_add"));
users.setUser_email(rs.getString("user_email"));
users.setUser_xueli(rs.getString("user_xueli"));
users.setDep_Name(rs.getString("dep_Name"));
users.setUser_beizu(rs.getString("user_beizu"));
list.add(users);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public List<Users> findByPro(String proName,String proValue)
{
String sql="select * from users where "+proName+" like '%"+proValue+"%'";
List<Users> list=new ArrayList<Users>();
Users users=null;
try {
Statement statement=conn.createStatement();
ResultSet rs=statement.executeQuery(sql);
while(rs.next())
{
users=new Users();
users.setUser_id(rs.getString("user_id"));
users.setUser_name(rs.getString("user_name"));
users.setUser_sex(rs.getString("user_sex"));
users.setUser_birthday(rs.getDate("user_birthday"));
users.setUser_minzu(rs.getString("user_minzu"));
users.setUser_mianmao(rs.getString("user_mianmao"));
users.setUser_tell(rs.getString("user_tell"));
users.setUser_add(rs.getString("user_add"));
users.setUser_email(rs.getString("user_email"));
users.setUser_xueli(rs.getString("user_xueli"));
users.setDep_Name(rs.getString("dep_Name"));
users.setUser_beizu(rs.getString("user_beizu"));
list.add(users);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public void closeConn()
{
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
管理员需要添加任何信息,点击添加按钮,给出添加信息界面,管理员输入需要添加信息,点击确定添加按钮,完成信息的录入。不需要的信息需要删除时,通过点击删除按钮,实现删除操作。需要修改的信息通过点击修改按钮,给出修改信息界面,管理员修改需要修改和允许修改的信息,实现信息修改功能。管理员需要查询信息时,通过输入需要查询信息条件,点击查询按钮,查询出需要查询的信息,实现信息查询功能(查询功能可以使用模糊查询)。
资源推荐
资源详情
资源评论
收起资源包目录
JavaWeb SQL 人力资源管理系统 (238个子文件)
UsersDAO.class 6KB
MoneyDAO.class 5KB
DepartusersExDAO.class 5KB
KehuDAO.class 4KB
NewsDAO.class 4KB
DeparmoneyExDAO.class 4KB
DepartmentDAO.class 4KB
ChengfaDAO.class 4KB
DeparchengfaExDAO.class 4KB
deparPagesAction.class 3KB
deparPageAction.class 3KB
chengfaPagesAction.class 3KB
chengfaPageAction.class 3KB
moneyPagesAction.class 3KB
usersPagesAction.class 3KB
usersPageAction.class 3KB
moneyPageAction.class 3KB
kehuPagesAction.class 3KB
newsPagesAction.class 3KB
newsPageAction.class 3KB
kehuPageAction.class 3KB
DepartusersEx.class 3KB
Users.class 3KB
AdminDAO.class 3KB
newsAddAction.class 2KB
DeparmoneyEx.class 2KB
Money.class 2KB
LoginAction.class 2KB
chengfaEditAction.class 2KB
usersEditAction.class 2KB
moneyEditAction.class 2KB
chengfaAddAction.class 2KB
moneyAddAction.class 2KB
usersAddAction.class 2KB
deparSearchAction.class 2KB
chengfaSearchAction.class 2KB
usersSearchAction.class 2KB
moneySearchAction.class 2KB
newsSearchAction.class 1KB
kehuSearchAction.class 1KB
Kehu.class 1KB
chengfaEditedAction.class 1KB
moneyEditedAction.class 1KB
News.class 1KB
adminPwdEditedAction.class 1KB
DeparchengfaEx.class 1KB
Chengfa.class 1KB
Department.class 1KB
usersEditedAction.class 1KB
deparEditAction.class 1KB
deparAddAction.class 1KB
chengfaExAction.class 1KB
departmentListThreeAction.class 1KB
adminPwdEditAction.class 1KB
departmentListTwoAction.class 1KB
departmentListAction.class 1KB
kehuAddAction.class 1KB
newsEditAction.class 1KB
kehuEditAction.class 1KB
alldeparAction.class 1KB
deparExAction.class 1023B
allchengfaAction.class 1008B
allusersAction.class 996B
allnewsAction.class 988B
allmoneyAction.class 986B
moneyExAction.class 983B
usersExAction.class 983B
SqlConn.class 981B
allkehuAction.class 975B
newsExAction.class 972B
kehuExAction.class 972B
Admin.class 966B
deparEditedAction.class 819B
chengfaDelAction.class 780B
deparDelAction.class 780B
usersDelAction.class 770B
moneyDelAction.class 770B
newsEditedAction.class 768B
kehuEditedAction.class 768B
newsDelAction.class 765B
kehuDelAction.class 765B
.classpath 880B
org.eclipse.wst.common.component 459B
org.eclipse.wst.jsdt.ui.superType.container 49B
calendar.css 2KB
Thumbs.db 20KB
title.gif 34KB
login_04.gif 22KB
login_11.gif 9KB
login_06.gif 5KB
login_10.gif 4KB
login_03.gif 4KB
login_07.gif 3KB
login_08.gif 2KB
login_09.gif 2KB
dl.gif 813B
cz.gif 796B
edit.gif 609B
yzm.gif 307B
UsersDAO.java 6KB
共 238 条
- 1
- 2
- 3
资源评论
- xiaoenwode2014-04-02运行没成功
- 好心司机2014-02-27功能基本都实现了。
love开源之hero
- 粉丝: 3
- 资源: 27
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于java的疗养院管理系统设计与实现.docx
- 基于java的旅游管理系统设计与实现.docx
- 基于java的人事管理系统设计与实现.docx
- 基于java的青年公寓服务平台设计与实现.docx
- 基于java的企业员工薪酬关系系统设计与实现.docx
- 西门子S7-300博途植物萃取饮料生产线控制系统程序案例,编程软件采用博途STEP7加博途WINCC RT Pro 内有CAD工艺流程图和PDF版电气图供参考 博图版本V15.1及以上23
- 基于java的失物招领平台设计与实现.docx
- 基于java的社区养老服务系统设计与实现.docx
- 基于java的乡政府管理系统设计与实现.docx
- 基于java的小区团购管理系统设计与实现.docx
- 基于java的校园资产管理系统设计与实现.docx
- 基于java的小学生身体素质测评管理系统设计与实现.docx
- 基于java的信息技术知识赛系统设计与实现.docx
- 基于java的疫情管理系统设计与实现.docx
- 基于java的学生网上选课系统设计与实现.docx
- 基于java的在线互动学习网站设计与实现.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功