public boolean flag(user ue) {
userdb db = new userdb();
boolean flag = true;
PreparedStatement pst = null;
ResultSet rs = null;
/* String uname=ue.getUname();
Statement st=null;
String upwd=ue.getUpwd();
String sql1= "select * from users where uname= ' "+uname+ " ' and upwd= ' "+upwd+ " ' ";*/
String sql = "select * from users where uname=? and upwd=? ";
try {
pst = db.getPrepareStatement(sql);
pst.setString(1, ue.getUname());
pst.setString(2, ue.getUpwd());
rs = pst.executeQuery();
//st=db.getStatement();
//rs = st.executeQuery(sql1);
if (rs.next()) {
flag = true;
//ue.setUname(rs.getString(1));
} else {
flag = false;
}
rs.close();
pst.close();
} catch (Exception e) {
System.out.println(e);
} finally {
// 最后一定要保证数据库已被关闭
db.close();
}