package dao;

import utils.DataBaseUtil;
import java.sql.*;

public class UserDao {

    public boolean isUserExist(String userName,String passWord) {
        //create a connection
        Connection connection = DataBaseUtil.getConnection();

        String sql ="select * from tb_user WHERE username=? and password=?";
        try{
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,userName);
            ps.setString(2,passWord);
            ResultSet resultSet = ps.executeQuery();
            if( resultSet.next() ) {
                return true;
            }
        }catch(SQLException e) {
            System.out.println(e.toString());
            e.printStackTrace();
        }catch(NullPointerException f){
            f.printStackTrace();
        }finally {
            DataBaseUtil.closeConnection(connection);
        }
        return false;
    }
}
最近下载更多
2017143155  LV12 2023年6月30日
495997956  LV1 2023年6月15日
000666  LV10 2022年12月24日
与哲rhcy  LV6 2022年12月4日
wangchengwen  LV15 2021年6月3日
园林属于  LV7 2021年5月27日
live1018  LV12 2021年5月24日
luchen  LV6 2021年3月23日
myy1111  LV3 2021年2月23日
唯你不离不弃  LV5 2021年1月21日
最近浏览更多
ITkuangren  LV8 2023年10月7日
hongdongdong  LV12 2023年9月3日
nbzhou2013  LV14 2023年8月4日
2017143155  LV12 2023年6月30日
gyuguigiu  LV1 2023年6月27日
mrcao95  LV2 2023年6月26日
训码士 2023年6月17日
暂无贡献等级
495997956  LV1 2023年6月15日
Merdan_810 2023年6月9日
暂无贡献等级
xxx520520  LV6 2023年5月31日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友