package com.ddChat.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.ddChat.model.User;
public class UserDao
{
private User user;
/**
* 登录验证
* @param con
* @param user
* @return
* @throws Exception
*/
public User login(Connection con,User user) throws Exception
{
User resultUser =null;
String sql = "select * from tb_user where userName=? and password=?";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, user.getUserName());
ps.setString(2, user.getPassword());
ResultSet rs = ps.executeQuery();
if(rs.next())
{
resultUser = new User();
resultUser.setUserName(rs.getString("userName"));
resultUser.setPassword(rs.getString("password"));
}
return resultUser;
}
}
阅读(1165) | 评论(0) | 转发(0) |