首页 > 代码库 > 修改密码的DAO部分
修改密码的DAO部分
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部分
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。