JSP??????sql?????
???????????? ???????[ 2014/5/30 14:58:15 ] ????????JSP sql??? sql
????SQL?????????????????????????????????????Web??ó???????Щ???????SQL??????Щ??????????SQL????????й?????????????????????????????????μ???????????????????????????????????
????prepareStatement????????sql???????Ч???
????preparedStatement??statement??????
????1??preparedStatement??statement???????
????2??preparedStatement??????sql????????
????3??preparedStatement????????????????sql????????????????????????
???????????
public User find??String username?? String password?? {
Connection conn = null;
PreparedStatement st = null;
ResultSet rs = null;
try{
conn = JdbcUtils.getConnection??????
String sql = "select * from users where username=? and password=?";
st = conn.prepareStatement??sql????
st.setString??1?? username????
st.setString??2?? password????
rs = st.executeQuery?????? //
if??rs.next??????{
User user = new User??????
user.setId??rs.getString??"id"??????
user.setUsername??rs.getString??"username"??????
user.setPassword??rs.getString??"password"??????
user.setEmail??rs.getString??"email"??????
user.setBirthday??rs.getDate??"birthday"??????
return user;
}
return null;
}catch ??Exception e?? {
throw new DaoException??e????
}finally{
JdbcUtils.release??conn?? st?? rs????
}
}
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11