Code Room
Code reviewHard
Question
Review this Java (JDBC) batch that applies price adjustments to many products in one transaction.
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.
Learn the concepts
void applyAdjustments(Connection conn, Map<Long, BigDecimal> deltas) throws SQLException { conn.setAutoCommit(false); PreparedStatement ps = conn.prepareStatement( "UPDATE products SET price = price + ? WHERE id = ?"); for (Map.Entry<Long, BigDecimal> e : deltas.entrySet()) { ps.setBigDecimal(1, e.getValue()); ps.setLong(2, e.getKey()); ps.addBatch(); } ps.executeBatch(); conn.commit();}Run or narrate your approach, then ask the coach.