Slow SQL Server performance with multiple PreparedStatement loop
Here are some ideas to try:


You are not closing your PreparedStatements.  There might possibly be some slow down due to resource consumption or deadlock.  Use the try-with-resources feature so it will automatically close.

for (AgentUpdate update : updateList) {
    try (PreparedStatement ps = connection.prepareStatement(sql.toString())
    {
        // set parameters
        ps.executeUpdate();
    }
}

Alternatively, you are creating a custom query and creating a new PreparedStatement for each record.  Although you are optimizing individual queries by minimizing the number of fields you are updating, you are creating additional overhead by preparing a new statements for each record.  If you update every field for every row, you could re-use the same PreparedStatement, which may end up being more efficient (depending on the number of fields and length of data you are actually updating).  Just overwrite the values in the prepared statement and redo the executeUpdate() on it.

try (PreparedStatement ps = connection.prepareStatement(sql.toString())) {
    for (AgentUpdate update : updateList) {
        // set parameters
        ps.executeUpdate();
    }
}