@Override
public User login(String username, String password, int type) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
User user = null;
String sql = "select * from userinfo where username = ? and password = ? and type = ?";
try {
conn = JdbcUtil.getConnection();
ps = conn.prepareStatement(sql);
ps.setString(1, username);
ps.setString(2, password);
ps.setInt(3, type);
rs = ps.executeQuery();
if (rs.next()) {
String a = rs.getString("username");
String b = rs.getString("password");
String c = rs.getString("telephone");
int i = rs.getInt("type");
user = new User(a, b, c, i);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
JdbcUtil.free(rs, ps, conn);