首页 > 其他 > 详细

修改密码的DAO部分

时间:2017-07-14 15:55:24      阅读:665      评论:0      收藏:0      [点我收藏+]
 1 package org.lxh.mvcdemo.dao.impl;
 2 
 3 import java.sql.Connection;
 4 import java.sql.PreparedStatement;
 5 import java.sql.ResultSet;
 6 
 7 import org.lxh.mvcdemo.dao.IUserDAO;
 8 import org.lxh.mvcdemo.vo.User;
 9 
10 public class UserDAOImpl implements IUserDAO{
11     private Connection conn = null;
12     private PreparedStatement pstmt = null;
13     public UserDAOImpl(Connection conn){
14         this.conn = conn;
15     }
16 
17     public boolean findLogin(User user) throws Exception {
18         boolean flag = false;
19         try{
20             String sql = "SELECT name FROM user WHERE userid=? AND password=?";
21             this.pstmt = this.conn.prepareStatement(sql);
22             this.pstmt.setString(1, user.getUserid());
23             this.pstmt.setString(2, user.getPassword());
24             ResultSet rs = this.pstmt.executeQuery();
25             if(rs.next()){
26                 user.setName(rs.getString(1));
27                 flag = true;
28             }
29         }catch(Exception e){
30             throw e;
31         }finally{
32             if(this.pstmt != null){
33                 try{
34                     this.pstmt.close();
35                 }catch(Exception e){
36                     throw e;
37                 }
38             }
39         }
40         return flag;
41     }
42 
43     public boolean resetPassword(String password) throws Exception {
44         
45         boolean flag01 = true;    
46         String sql = "update user set password=‘jjjj‘ where userid=‘admin‘";
47         this.pstmt = this.conn.prepareStatement(sql);
48         if(this.pstmt.executeUpdate()>0){
49             flag01 = true;
50         }
51         this.pstmt.close();
52         return flag01;
53     }
54 }

 

修改密码的DAO部分

原文:http://www.cnblogs.com/XuGuobao/p/7170611.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!