今天要做的是登录功能,写接口什么的,可是觉得暂时在那个项目里应用不起来,就搁浅了
看了登录功能的一小部分实现
public class Dao{ public static int userLogin(Connection con, String phone, String password) { int x = 0; try { String sql = "SELECT COUNT(*) FROM user WHERE phone=? AND pwd=?"; PreparedStatement ps = con.prepareStatement(sql); ps.setString(1, phone); ps.setString(2, password); ResultSet rs = ps.executeQuery(); if (rs.next()) { x = rs.getInt(1); } } catch (Exception e) { e.printStackTrace(); x = -1; } return x; } }