@Override public User getUserDetails(String uname) { Connection con = null; try { con = DBConnectionFactory.getConnection(); Statement st = con.createStatement(); String sql = "select fname, lname, email, mobile, usertype " + "from user_details " + "where uname='" + uname + "'"; ResultSet rs = st.executeQuery(sql); if (rs.next()) { User u = new User(); u.setUname(uname); u.setFname(rs.getString(1)); u.setLname(rs.getString(2)); u.setEmail(rs.getString(3)); u.setMobile(rs.getString(4)); u.setUsertype(rs.getString(5)); return u; } } catch (SQLException e) { e.printStackTrace(); } finally { try { con.close(); } catch (SQLException e) { e.printStackTrace(); } } return null; }
public User getUser(String user) throws SQLException { start(); rs = stmt.executeQuery("SELECT * FROM userInfo WHERE username = '******'"); User rtrn = null; if (rs.next()) { rtrn = new User(); rtrn.setUserName(rs.getString(1)); rtrn.setPassWord(rs.getString(2)); rtrn.setFirstName(rs.getString(3)); rtrn.setLastName(rs.getString(4)); rtrn.setEmail(rs.getString(5)); long number = 0; String num = rs.getString(6); if (num != null) number = Long.parseLong(num.replace("-", "").replace("(", "").replace(")", "")); rtrn.setPhoneNumber(number); rtrn.setCity(rs.getString(7)); rtrn.setState(rs.getString(8)); rtrn.setRating(rs.getInt(9)); } close(); return rtrn; }