package com.dao.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import com.dao.UserDao; import com.entity.User; import com.util.DBUtils; public class UserDaoImpl implements UserDao{ @Override public User getUserByName(String username) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = DBUtils.getConnection(); ps = con.prepareStatement("SELECT * FROM t_user WHERE username=?"); ps.setString(1, username); rs = ps.executeQuery(); if (rs.next()) { return new User(rs.getInt("id"), rs.getString("username"), rs.getString("password")); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return null; } }

yrxxry LV2
2024年7月2日
ZYX_CC LV1
2024年6月3日
微信网友_6791236687548416 LV1
2023年12月23日
hongdongdong LV14
2023年10月28日
jiemomo LV12
2023年10月19日
wan4444 LV1
2023年6月29日
liuliuyl LV3
2023年6月18日
何建一 LV1
2023年5月24日
1379585889 LV11
2022年12月13日
不知道取什么名字12 LV1
2022年12月12日