package cn.edu.qust.news.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import cn.edu.qust.news.dao.AdminDao; import cn.edu.qust.news.domain.Admin; import cn.edu.qust.news.utils.JdbcUtil; public class AdminDao { public AdminDao() { // TODO Auto-generated constructor stub } public Admin findAdminByName(String adminName) { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; try { conn = JdbcUtil.getConnection(); stmt = conn .prepareStatement("select f_adminname from t_admin where f_adminname=?"); stmt.setString(1, adminName); rs = stmt.executeQuery(); if (rs.next()) { Admin admin = new Admin(); admin.setAdminName(rs.getString("f_adminname")); return admin; } else return null; } catch (Exception e) { throw new RuntimeException(e); } finally { JdbcUtil.release(rs, stmt, conn); } } public Admin findAdmin(String adminName, String passWord) { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; try { conn = JdbcUtil.getConnection(); stmt = conn .prepareStatement("select f_adminname,f_adminpassword from t_admin where f_adminname=? and f_adminpassword=?"); stmt.setString(1, adminName); stmt.setString(2, passWord); rs = stmt.executeQuery(); if (rs.next()) { Admin admin = new Admin(); admin.setAdminName(rs.getString("f_adminname")); admin.setAdminPassWord(rs.getString("f_adminpassword")); return admin; } else return null; } catch (Exception e) { throw new RuntimeException(e); } finally { JdbcUtil.release(rs, stmt, conn); } } public void updateAdmin(String passWord) { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; try { conn = JdbcUtil.getConnection(); stmt = conn .prepareStatement("update t_admin set f_adminpassword=?"); stmt.setString(1, passWord); stmt.executeUpdate(); } catch (Exception e) { throw new RuntimeException(e); } finally { JdbcUtil.release(rs, stmt, conn); } } }
最近下载更多
asddwh LV12
2023年12月29日
19542347615 LV1
2023年11月23日
无名氏111 LV32
2023年11月18日
lwlwlwlw LV3
2023年6月17日
傻瓜还没打死烦人 LV7
2022年12月6日
zhunishimian LV6
2022年10月30日
SQ2930501923 LV14
2022年10月16日
CHENHAOJUDA LV10
2022年6月15日
小丶无奈 LV10
2022年6月13日
dasdascccf LV10
2022年6月10日
最近浏览更多
wjh007 LV4
2月29日
GerryGim LV4
1月15日
Liang朝伟 LV1
1月5日
1345fwwhjb
1月4日
暂无贡献等级
13161895 LV1
2023年12月30日
hxy19991216 LV4
2023年12月29日
asddwh LV12
2023年12月26日
yuanshun LV6
2023年12月19日
洪徽宏
2023年12月15日
暂无贡献等级
Gujiangtao
2023年12月9日
暂无贡献等级