package dao;

import java.sql.*;

import demo.database;
import entity.Books;

public class Userdao {
	database db;public Books book;
	public Userdao(){
		book=new Books();
		db=new database();
	}
	public boolean dologin(String name,String pwd){	
		Connection con =db.getConnection();//建立数据库连接,获得Connection对象。
		if(con==null)
			System.out.println("连接数据库失败");
		//创建SQL语句
		String sql="select * from users where LoginId=? and LoginPwd=?";
			try {
			PreparedStatement stmt=con.prepareStatement(sql);//根据SOL语句建立PreparedStatement对象
			stmt.setString(1, name);//设置参数
			stmt.setString(2, pwd);//设置参数
			ResultSet rSet=stmt.executeQuery();//执行SQL语句
			if(rSet.next()){
				return true;
				}else{
					return false;
				}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	finally{
			db.CloseConnection(con);//关闭数据库连接,释放资源
		}
		return false;
}
			}
最近下载更多
孤峰远影  LV2 2023年12月20日
768881787  LV7 2023年12月20日
微信网友_6445756515635200  LV3 2023年12月18日
李朝磊  LV18 2023年12月3日
hongdongdong  LV14 2023年8月9日
微信网友_6431017932869632  LV1 2023年4月13日
ma2519096  LV1 2022年11月26日
你们的代码都是我的了  LV16 2022年11月13日
微信网友_6017665021366272  LV1 2022年6月25日
1719863922  LV11 2022年6月13日
最近浏览更多
chengjingjingjing 6月17日
暂无贡献等级
15592940706  LV3 6月16日
曾纪荣 3月2日
暂无贡献等级
pxqtsht  LV16 2月21日
无异偶  LV3 2024年12月30日
momomo228  LV2 2024年11月22日
233002037  LV3 2024年10月20日
dnuygwqudyg 2024年6月28日
暂无贡献等级
xzw135246789  LV1 2024年6月15日
微信网友_6808953284677632  LV2 2024年6月5日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友