Why this matters
Eases maintenance, reuse, and prevents typos.
Define SQL strings as static final constants or in a repository, not inline across methods.
Eases maintenance, reuse, and prevents typos.
Side-by-side examples engineers can pattern-match during review.
conn.prepareStatement("SELECT * FROM orders WHERE id=?");private static final String SQL_GET_ORDER = "SELECT * FROM orders WHERE id=?";
conn.prepareStatement(SQL_GET_ORDER);"UPDATE t SET..." scatteredstatic final String SQL = "UPDATE t SET...";From the same buckets as this rule.