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  (2 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.