首页>代码>jsp+mysql开发最简单的商品增删改查的实例>/prjtest/src/com/phome/db/UsersDao.java
package com.phome.db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.phome.vo.UsersVo;

public class UsersDao {
	public UsersVo getUsersByNameAndPwd(String name,String pwd)
	{
		String sql="select * from users where uname=? and upass=?";
		DbHelper dbhelp=new DbHelper();
		Connection conn=null;
		PreparedStatement pst=null;
		try {
			conn=dbhelp.getConnect();
			pst=conn.prepareStatement(sql);
			pst.setString(1, name);
			pst.setString(2, pwd);
			ResultSet rs=pst.executeQuery();
			if (rs.next())
			{
				UsersVo user = new UsersVo();
				user.setId(rs.getInt("id"));
				user.setName(rs.getString("uname"));
				user.setPwd(rs.getString("upass"));
				user.setSex(rs.getInt("sex"));
				user.setFavs(rs.getString("favs"));
				user.setCity(rs.getString("city"));
				user.setJianjie(rs.getString("jianjie"));
				return user;
			
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			try {
				if (pst!=null)
				{
					pst.close();
				}
				if (conn!=null && !conn.isClosed())
				{
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return null;
	}
}
最近下载更多
hongdongdong  LV14 2024年5月6日
一起加油  LV5 2024年4月19日
PSSDZH  LV3 2024年1月22日
asddwh  LV13 2023年12月25日
wdawdawda  LV1 2023年11月12日
下雨了z  LV1 2023年6月25日
ericxu1116  LV24 2023年6月14日
sdhfkh  LV4 2023年6月12日
jiuyue1  LV1 2023年6月7日
微信网友_6509411715747840  LV1 2023年6月7日
最近浏览更多
taoshen95  LV16 3月23日
angbors  LV1 2024年12月3日
PISCESPLUS  LV5 2024年9月3日
ma406805131  LV19 2024年6月29日
ming_123_9715  LV23 2024年6月19日
Kaiaahh  LV2 2024年6月11日
hongdongdong  LV14 2024年5月6日
一起加油  LV5 2024年4月19日
xinnnnn  LV1 2024年2月28日
PSSDZH  LV3 2024年1月22日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友