package dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import entity.User;
import utils.DataBaseUtil;
public class UserDao {
public User login(String username,String pwd){
User user=null;
//
获取数据库连接
Connection conn=DataBaseUtil.getConnection();
String sql="select * from tb_user where username=? and password=?";
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, username);
ps.setString(2, pwd);
//
用
ResultSet
存储查到的内容
ResultSet rs=ps.executeQuery();
if(rs.next()){//
查到了数据