private void persist(FinishedJobRecord r) {
        StringBuilder sb = new StringBuilder("SELECT ");
        sb.append(JOB_ID_COLUMN);
        sb.append(" FROM ");
        sb.append(FINISHED_JOBS_TABLE);
        sb.append(" WHERE ");
        sb.append(JOB_ID_COLUMN);
        sb.append("='");
        sb.append(r.job_number);

        if (r.task_number > 0) {
            sb.append(".");
            sb.append(r.task_number);
        }
        sb.append("'");

        try {
            ResultSet rs = executeQuery(sb.toString());
            if (rs != null && rs.next()) {;
                // already persisted
                return;
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }

        sb = new StringBuilder("INSERT INTO ");

        sb.append(FINISHED_JOBS_TABLE);
        sb.append(" (");
        sb.append(JOB_ID_COLUMN);
        sb.append(",");
        sb.append(START_TIME_COLUMN);
        sb.append(",");
        sb.append(END_TIME_COLUMN);
        sb.append(",");
        sb.append(EXIT_STATUS_COLUMN);
        sb.append(") VALUES (?,?,?,?)");



        Connection conn = acquireConnection();

        try {
            PreparedStatement stmt = conn.prepareStatement(sb.toString());

            String jobId = r.job_number;

            if (r.task_number > 0) {
                jobId += "." + r.task_number;
            }

            long startTime = r.start_time;
            long endTime = r.end_time;

            if (startTime == endTime) {
                Double utime = Double.parseDouble(r.ru_utime);

                if (utime != null && utime > 0) {
                    endTime += utime * 1000;
                }
            }

            stmt.setString(1, jobId);
            stmt.setLong(2, r.start_time);
            stmt.setLong(3, r.end_time);
            stmt.setInt(4, r.exit_status);

            stmt.execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            releaseConnection(conn);
        }
    }