Code Room
Code reviewMediumcr-g642
Subject Sql query performanceLevel Mid–Senior~20 minCommon in Databases & SQL interviewsIndustries Software development

Question

Review this Java DAO method that checks whether a user can log in.

The `users` table has a 4KB `bio` TEXT column, a `profile_json` JSONB column, and an avatar BYTEA.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
public boolean isActive(long userId) {    String sql = "SELECT * FROM users WHERE id = ?";    try (PreparedStatement ps = conn.prepareStatement(sql)) {        ps.setLong(1, userId);        try (ResultSet rs = ps.executeQuery()) {            if (rs.next()) {                return "active".equals(rs.getString("status"));            }            return false;        }    }}
Run or narrate your approach, then ask the coach.