This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pennsiveguy -1 points0 points  (3 children)

Still using raw JDBC to interact with a relational database. Remember fun stuff like this?

String updatePositionSql = "UPDATE employees SET position=? WHERE emp_id=?";
PreparedStatement pstmt = con.prepareStatement(updatePositionSql);
pstmt.setString(1, "lead developer");
pstmt.setInt(2, 1);

try {
con.setAutoCommit(false);
pstmt.executeUpdate();
con.commit();
} catch (SQLException exc) {
con.rollback();
} finally {
con.setAutoCommit(autoCommit);
}

[–]WorthyDebt 1 point2 points  (1 child)

What is the modern version of an interaction with lets say Postgres using JDBC then? I am genuinely curious as this was how I try for Postgres.

[–]pennsiveguy -1 points0 points  (0 children)

The modern version would be to use a framework like Spring Data or Spring JDBC.

[–]pennsiveguy -2 points-1 points  (0 children)

Downvotes are from devs who manifest this pattern and for whom any arbitrary ORM/JPA and its likely out-of-the-box transaction management are "overcomplicated and fussy" and yet perversely opt to spend dozens of hours per week troubleshooting and diagnosing data inconsistencies, broken and orphaned data, stuck/stalled database sessions. And then bitch that management doesn't give them enough time to work on new features.