首页>代码>jsp+servlet+easyUI+jquery+echarts开发高速公路事故后台信息管理系统>/OneProject/src/com/wu/action/AdminLoignImpl.java
                
                package com.wu.action;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.wu.Service.AdminLoginI;
import com.wu.bean.Admin;
import com.wu.util.DbUtil;;
public class AdminLoignImpl implements AdminLoginI {
	/**
	 * 管理员登陆
	 */
	@Override
	public boolean userLogin(Admin user) {
		Connection conn = null;
		PreparedStatement pst = null;
		ResultSet rs = null;
		String sql="select Ad_name,Ad_passwd from admin";
		try {
			conn = DbUtil.getConnection();
			pst = conn.prepareStatement(sql);
			rs = pst.executeQuery();
			while (rs.next()) {
				Admin admin1 = new Admin();
				admin1.setPassword(rs.getString("Ad_passwd"));
				admin1.setUsername(rs.getString("Ad_name"));
				if(admin1.toString().equals(user.toString())){
					return true;
				}
			}
			DbUtil.closeAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	/**
	 * 管理员修改密码
	 */
	@Override
	public boolean changepasswd(Admin user, String newPasswd) {
		int result=0;
		Connection conn = null;
		PreparedStatement pst = null;
		ResultSet rs = null;
		String sql = "update admin set Ad_passwd=? where Ad_name=? and Ad_passwd=?";
		try {
			conn = DbUtil.getConnection();
			pst = conn.prepareStatement(sql);
			pst.setString(1, newPasswd);
			pst.setString(2, user.getUsername());
			pst.setString(3, user.getPassword());
			result = pst.executeUpdate();
			conn.setAutoCommit(true);
			DbUtil.closeAll();
			if(result!=0){
				return true;
			}
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return false;
	}
	@Override
	public boolean register(Admin user) {
		int result=0;
		Connection conn = null;
		PreparedStatement pst = null;
		String sql = "insert into  admin(Ad_passwd,Ad_name)  values(?,?)";
		try {
			conn = DbUtil.getConnection();
			pst = conn.prepareStatement(sql);
			pst.setString(1, user.getPassword());
			pst.setString(2, user.getUsername());
			result = pst.executeUpdate();
			conn.setAutoCommit(true);
			DbUtil.closeAll();
			if(result!=0){
				return true;
			}
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return false;
	}
	
}
 最近下载更多
最近下载更多
                
                171337601     LV9
                2022年4月18日
            
            
        
                nitama     LV19
                2021年5月16日
            
            
        
                ericxu1116     LV24
                2021年4月26日
            
            
        
                rebecca0214     LV2
                2021年4月14日
            
            
        
                ly_fxm     LV4
                2021年1月31日
            
            
        
                naixia     LV9
                2020年7月8日
            
            
        
                芳华林     LV11
                2020年6月18日
            
            
        
                骄傲的时刻     LV2
                2020年5月16日
            
            
        
                KING QIN     LV5
                2020年5月12日
            
            
        
                TerryGaoBo     LV9
                2020年4月28日
            
            
        
 
                 
     
                 最近浏览
最近浏览