Example usage for java.sql PreparedStatement setTimestamp

List of usage examples for java.sql PreparedStatement setTimestamp

Introduction

In this page you can find the example usage for java.sql PreparedStatement setTimestamp.

Prototype

void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws SQLException;

Source Link

Document

Sets the designated parameter to the given java.sql.Timestamp value.

Usage

From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java

@Override
public void update(final Pand origineel, final Pand mutation) throws DAOException {
    try {//from w  ww  .  j a va  2s.  c o  m
        jdbcTemplate.update(new PreparedStatementCreator() {
            @Override
            public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                PreparedStatement ps = connection.prepareStatement("update bag_pand set"
                        + " aanduiding_record_inactief = ?," + " aanduiding_record_correctie = ?,"
                        + " officieel = ?," + " pand_geometrie = ?," + " bouwjaar = ?," + " pand_status = ?,"
                        + " einddatum_tijdvak_geldigheid = ?," + " in_onderzoek = ?,"
                        + " bron_documentdatum = ?," + " bron_documentnummer = ?" + " where bag_pand_id = ?"
                        + " and aanduiding_record_correctie = ?" + " and begindatum_tijdvak_geldigheid = ?");
                ps.setInt(1, mutation.getAanduidingRecordInactief().ordinal());
                ps.setLong(2, mutation.getAanduidingRecordCorrectie());
                ps.setInt(3, mutation.getOfficieel().ordinal());
                ps.setString(4, mutation.getPandGeometrie());
                ps.setInt(5, mutation.getBouwjaar());
                ps.setString(6, mutation.getPandStatus());
                if (mutation.getEinddatumTijdvakGeldigheid() == null)
                    ps.setNull(7, Types.TIMESTAMP);
                else
                    ps.setTimestamp(7, new Timestamp(mutation.getEinddatumTijdvakGeldigheid().getTime()));
                ps.setInt(8, mutation.getInOnderzoek().ordinal());
                ps.setDate(9, new Date(mutation.getDocumentdatum().getTime()));
                ps.setString(10, mutation.getDocumentnummer());
                ps.setLong(11, origineel.getIdentificatie());
                ps.setLong(12, origineel.getAanduidingRecordCorrectie());
                ps.setTimestamp(13, new Timestamp(origineel.getBegindatumTijdvakGeldigheid().getTime()));
                return ps;
            }
        });
    } catch (DataAccessException e) {
        throw new DAOException("Error updating pand: " + origineel.getIdentificatie(), e);
    }
}

From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java

@Override
public void update(final Woonplaats origineel, final Woonplaats wijziging) throws DAOException {
    try {/*from ww  w  .j  ava 2  s.  c  o  m*/
        jdbcTemplate.update(new PreparedStatementCreator() {
            @Override
            public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                PreparedStatement ps = connection.prepareStatement("update bag_woonplaats set"
                        + " aanduiding_record_inactief = ?," + " aanduiding_record_correctie = ?,"
                        + " woonplaats_naam = ?," + " woonplaats_geometrie = ?," + " officieel = ?,"
                        + " einddatum_tijdvak_geldigheid = ?," + " in_onderzoek = ?,"
                        + " bron_documentdatum = ?," + " bron_documentnummer = ?," + " woonplaats_status = ?"
                        + " where bag_woonplaats_id = ?" + " and aanduiding_record_correctie = ?"
                        + " and begindatum_tijdvak_geldigheid = ?");
                ps.setInt(1, wijziging.getAanduidingRecordInactief().ordinal());
                ps.setLong(2, wijziging.getAanduidingRecordCorrectie());
                ps.setString(3, wijziging.getWoonplaatsNaam());
                ps.setString(4, wijziging.getWoonplaatsGeometrie());
                ps.setInt(5, wijziging.getOfficieel().ordinal());
                if (wijziging.getEinddatumTijdvakGeldigheid() == null)
                    ps.setNull(6, Types.TIMESTAMP);
                else
                    ps.setTimestamp(6, new Timestamp(wijziging.getEinddatumTijdvakGeldigheid().getTime()));
                ps.setInt(7, wijziging.getInOnderzoek().ordinal());
                ps.setDate(8, new Date(wijziging.getDocumentdatum().getTime()));
                ps.setString(9, wijziging.getDocumentnummer());
                ps.setInt(10, wijziging.getWoonplaatsStatus().ordinal());
                ps.setLong(11, origineel.getIdentificatie());
                ps.setLong(12, origineel.getAanduidingRecordCorrectie());
                ps.setTimestamp(13, new Timestamp(origineel.getBegindatumTijdvakGeldigheid().getTime()));
                return ps;
            }
        });
    } catch (DataAccessException e) {
        throw new DAOException("Error updating woonplaats: " + origineel.getIdentificatie(), e);
    }
}

From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java

@Override
public void insert(final Ligplaats ligplaats) throws DAOException {
    try {/*from  w w w.  j ava 2s .com*/
        transactionTemplate.execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                jdbcTemplate.update(new PreparedStatementCreator() {
                    @Override
                    public PreparedStatement createPreparedStatement(Connection connection)
                            throws SQLException {
                        PreparedStatement ps = connection
                                .prepareStatement("insert into bag_ligplaats (" + "bag_ligplaats_id,"
                                        + "aanduiding_record_inactief," + "aanduiding_record_correctie,"
                                        + "officieel," + "ligplaats_status," + "ligplaats_geometrie,"
                                        + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid,"
                                        + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer,"
                                        + "bag_nummeraanduiding_id" + ") values (?,?,?,?,?,?,?,?,?,?,?,?)");
                        ps.setLong(1, ligplaats.getIdentificatie());
                        ps.setInt(2, ligplaats.getAanduidingRecordInactief().ordinal());
                        ps.setLong(3, ligplaats.getAanduidingRecordCorrectie());
                        ps.setInt(4, ligplaats.getOfficieel().ordinal());
                        ps.setInt(5, ligplaats.getLigplaatsStatus().ordinal());
                        ps.setString(6, ligplaats.getLigplaatsGeometrie());
                        ps.setTimestamp(7, new Timestamp(ligplaats.getBegindatumTijdvakGeldigheid().getTime()));
                        if (ligplaats.getEinddatumTijdvakGeldigheid() == null)
                            ps.setNull(8, Types.TIMESTAMP);
                        else
                            ps.setTimestamp(8,
                                    new Timestamp(ligplaats.getEinddatumTijdvakGeldigheid().getTime()));
                        ps.setInt(9, ligplaats.getInOnderzoek().ordinal());
                        ps.setDate(10, new Date(ligplaats.getDocumentdatum().getTime()));
                        ps.setString(11, ligplaats.getDocumentnummer());
                        ps.setLong(12, ligplaats.getHoofdAdres());
                        return ps;
                    }
                });
                insertNevenadressen(TypeAdresseerbaarObject.LIGPLAATS, ligplaats);
            }
        });
    } catch (DataAccessException e) {
        throw new DAOException("Error inserting ligplaats: " + ligplaats.getIdentificatie(), e);
    }
}

From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java

@Override
public Event findEventByExtIdAndRecurrenceId(AccessToken token, ObmUser calendar, EventExtId extId,
        RecurrenceId recurrenceId) throws ParseException {

    String ev = "SELECT " + EVENT_SELECT_FIELDS + ", eventexception_date as recurrence_id " + " FROM Event e "
            + "LEFT JOIN EventCategory1 ON e.event_category1_id=eventcategory1_id "
            + "LEFT JOIN EventException eexp ON e.event_id = eventexception_child_id "
            + "INNER JOIN Domain ON event_domain_id=domain_id "
            + "INNER JOIN EventEntity ON evententity_event_id=event_id "
            + "INNER JOIN EventLink link ON link.eventlink_event_id=e.event_id "
            + "INNER JOIN UserEntity ON userentity_entity_id=eventlink_entity_id "
            + "INNER JOIN UserObm u ON u.userobm_id=userentity_user_id "
            + "INNER JOIN UserObm o ON e.event_owner=o.userobm_id "
            + "INNER JOIN UserObm c ON e.event_usercreate=c.userobm_id " + "WHERE e.event_ext_id=? "
            + "AND eexp.eventexception_date=?" + "AND u.userobm_login=?";

    PreparedStatement evps = null;
    ResultSet evrs = null;/*from  w  w w  .j av  a2  s . c o m*/
    Connection con = null;

    try {
        con = obmHelper.getConnection();
        evps = con.prepareStatement(ev);
        evps.setString(1, extId.getExtId());

        Date recId = new DateTime(recurrenceId.getRecurrenceId());
        evps.setTimestamp(2, new Timestamp(recId.getTime()));
        evps.setString(3, calendar.getLogin());

        evrs = evps.executeQuery();
        if (evrs.next()) {
            Calendar cal = getGMTCalendar();
            Event ret = eventFromCursor(cal, evrs);
            String domainName = evrs.getString("domain_name");
            Map<EventObmId, Event> eventById = ImmutableMap.of(ret.getObmId(), ret);
            IntegerIndexedSQLCollectionHelper eventIds = new IntegerIndexedSQLCollectionHelper(
                    ImmutableList.of(ret));
            loadAttendees(con, eventById, domainName);
            loadAlerts(con, token, eventById, eventIds);
            return ret;
        }
    } catch (SQLException e) {
        logger.error(e.getMessage(), e);
    } catch (ParseException e) {
        logger.error(e.getMessage(), e);
        throw e;
    } finally {
        obmHelper.cleanup(con, evps, evrs);
    }
    return null;
}

From source file:nl.nn.adapterframework.jdbc.JdbcTransactionalStorage.java

protected String storeMessageInDatabase(Connection conn, String messageId, String correlationId,
        Timestamp receivedDateTime, String comments, String label, Serializable message)
        throws IOException, SQLException, JdbcException, SenderException {
    PreparedStatement stmt = null;
    try {/*www .j av  a 2s.  c o  m*/
        IDbmsSupport dbmsSupport = getDbmsSupport();
        if (log.isDebugEnabled())
            log.debug("preparing insert statement [" + insertQuery + "]");
        if (!dbmsSupport.mustInsertEmptyBlobBeforeData()) {
            stmt = conn.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS);
        } else {
            stmt = conn.prepareStatement(insertQuery);
        }
        stmt.clearParameters();
        int parPos = 0;

        if (StringUtils.isNotEmpty(getTypeField())) {
            stmt.setString(++parPos, type);
        }
        if (StringUtils.isNotEmpty(getSlotId())) {
            stmt.setString(++parPos, getSlotId());
        }
        if (StringUtils.isNotEmpty(getHostField())) {
            stmt.setString(++parPos, host);
        }
        if (StringUtils.isNotEmpty(getLabelField())) {
            stmt.setString(++parPos, label);
        }
        stmt.setString(++parPos, messageId);
        stmt.setString(++parPos, correlationId);
        stmt.setTimestamp(++parPos, receivedDateTime);
        stmt.setString(++parPos, comments);
        if (type.equalsIgnoreCase(TYPE_MESSAGELOG_PIPE) || type.equalsIgnoreCase(TYPE_MESSAGELOG_RECEIVER)) {
            if (getRetention() < 0) {
                stmt.setTimestamp(++parPos, null);
            } else {
                Date date = new Date();
                Calendar cal = Calendar.getInstance();
                cal.setTime(date);
                cal.add(Calendar.DAY_OF_MONTH, getRetention());
                stmt.setTimestamp(++parPos, new Timestamp(cal.getTime().getTime()));
            }
        } else {
            stmt.setTimestamp(++parPos, null);
        }

        if (!isStoreFullMessage()) {
            if (isOnlyStoreWhenMessageIdUnique()) {
                stmt.setString(++parPos, messageId);
                stmt.setString(++parPos, slotId);
            }
            stmt.execute();
            return null;
        }
        if (!dbmsSupport.mustInsertEmptyBlobBeforeData()) {
            ByteArrayOutputStream out = new ByteArrayOutputStream();

            if (isBlobsCompressed()) {
                DeflaterOutputStream dos = new DeflaterOutputStream(out);
                ObjectOutputStream oos = new ObjectOutputStream(dos);
                oos.writeObject(message);
                dos.close();
            } else {
                ObjectOutputStream oos = new ObjectOutputStream(out);
                oos.writeObject(message);
            }

            stmt.setBytes(++parPos, out.toByteArray());
            if (isOnlyStoreWhenMessageIdUnique()) {
                stmt.setString(++parPos, messageId);
                stmt.setString(++parPos, slotId);
            }
            stmt.execute();
            ResultSet rs = stmt.getGeneratedKeys();
            if (rs.next()) {
                return rs.getString(1);
            } else {
                return null;
            }
        }
        if (isOnlyStoreWhenMessageIdUnique()) {
            stmt.setString(++parPos, messageId);
            stmt.setString(++parPos, slotId);
        }
        stmt.execute();
        int updateCount = stmt.getUpdateCount();
        if (log.isDebugEnabled())
            log.debug("update count for insert statement: " + updateCount);
        if (updateCount > 0) {
            if (log.isDebugEnabled())
                log.debug("preparing select statement [" + selectKeyQuery + "]");
            stmt = conn.prepareStatement(selectKeyQuery);
            ResultSet rs = null;
            try {
                // retrieve the key
                rs = stmt.executeQuery();
                if (!rs.next()) {
                    throw new SenderException("could not retrieve key of stored message");
                }
                String newKey = rs.getString(1);
                rs.close();

                // and update the blob
                if (log.isDebugEnabled())
                    log.debug("preparing update statement [" + updateBlobQuery + "]");
                stmt = conn.prepareStatement(updateBlobQuery);
                stmt.clearParameters();
                stmt.setString(1, newKey);

                rs = stmt.executeQuery();
                if (!rs.next()) {
                    throw new SenderException("could not retrieve row for stored message [" + messageId + "]");
                }
                //                  String newKey = rs.getString(1);
                //                  BLOB blob = (BLOB)rs.getBlob(2);
                Object blobHandle = dbmsSupport.getBlobUpdateHandle(rs, 1);
                OutputStream out = dbmsSupport.getBlobOutputStream(rs, 1, blobHandle);
                //               OutputStream out = JdbcUtil.getBlobUpdateOutputStream(rs,1);
                if (isBlobsCompressed()) {
                    DeflaterOutputStream dos = new DeflaterOutputStream(out);
                    ObjectOutputStream oos = new ObjectOutputStream(dos);
                    oos.writeObject(message);
                    oos.close();
                    dos.close();
                } else {
                    ObjectOutputStream oos = new ObjectOutputStream(out);
                    oos.writeObject(message);
                    oos.close();
                }
                out.close();
                dbmsSupport.updateBlob(rs, 1, blobHandle);
                return newKey;

            } finally {
                if (rs != null) {
                    rs.close();
                }
            }
        } else {
            if (isOnlyStoreWhenMessageIdUnique()) {
                return "already there";
            } else {
                throw new SenderException(
                        "update count for update statement not greater than 0 [" + updateCount + "]");
            }
        }

    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
}

From source file:com.mirth.connect.donkey.server.data.jdbc.JdbcDao.java

@Override
public void updateSendAttempts(ConnectorMessage connectorMessage) {
    logger.debug(connectorMessage.getChannelId() + "/" + connectorMessage.getMessageId()
            + ": updating send attempts");

    Calendar sendDate = connectorMessage.getSendDate();
    Calendar responseDate = connectorMessage.getResponseDate();

    try {//w  ww  .j  av  a2 s.c om
        PreparedStatement statement = prepareStatement("updateSendAttempts", connectorMessage.getChannelId());
        statement.setInt(1, connectorMessage.getSendAttempts());
        statement.setTimestamp(2, sendDate == null ? null : new Timestamp(sendDate.getTimeInMillis()));
        statement.setTimestamp(3, responseDate == null ? null : new Timestamp(responseDate.getTimeInMillis()));
        statement.setInt(4, connectorMessage.getMetaDataId());
        statement.setLong(5, connectorMessage.getMessageId());
        statement.setString(6, connectorMessage.getServerId());
        statement.executeUpdate();
    } catch (SQLException e) {
        throw new DonkeyDaoException(e);
    }
}

From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java

@Override
public void insert(final Standplaats standplaats) throws DAOException {
    try {/* ww  w  .j a  v  a2s . c  o m*/
        transactionTemplate.execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                jdbcTemplate.update(new PreparedStatementCreator() {
                    @Override
                    public PreparedStatement createPreparedStatement(Connection connection)
                            throws SQLException {
                        PreparedStatement ps = connection
                                .prepareStatement("insert into bag_standplaats (" + "bag_standplaats_id,"
                                        + "aanduiding_record_inactief," + "aanduiding_record_correctie,"
                                        + "officieel," + "standplaats_status," + "standplaats_geometrie,"
                                        + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid,"
                                        + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer,"
                                        + "bag_nummeraanduiding_id" + ") values (?,?,?,?,?,?,?,?,?,?,?,?)");
                        ps.setLong(1, standplaats.getIdentificatie());
                        ps.setInt(2, standplaats.getAanduidingRecordInactief().ordinal());
                        ps.setLong(3, standplaats.getAanduidingRecordCorrectie());
                        ps.setInt(4, standplaats.getOfficieel().ordinal());
                        ps.setInt(5, standplaats.getStandplaatsStatus().ordinal());
                        ps.setString(6, standplaats.getStandplaatsGeometrie());
                        ps.setTimestamp(7,
                                new Timestamp(standplaats.getBegindatumTijdvakGeldigheid().getTime()));
                        if (standplaats.getEinddatumTijdvakGeldigheid() == null)
                            ps.setNull(8, Types.TIMESTAMP);
                        else
                            ps.setTimestamp(8,
                                    new Timestamp(standplaats.getEinddatumTijdvakGeldigheid().getTime()));
                        ps.setInt(9, standplaats.getInOnderzoek().ordinal());
                        ps.setDate(10, new Date(standplaats.getDocumentdatum().getTime()));
                        ps.setString(11, standplaats.getDocumentnummer());
                        ps.setLong(12, standplaats.getHoofdAdres());
                        return ps;
                    }
                });
                insertNevenadressen(TypeAdresseerbaarObject.STANDPLAATS, standplaats);
            }
        });
    } catch (DataAccessException e) {
        throw new DAOException("Error inserting standplaats: " + standplaats.getIdentificatie(), e);
    }
}

From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java

private void insertExceptions(AccessToken editor, Event ev, Connection con, EventObmId id) throws SQLException {
    PreparedStatement ps = null;
    try {//from   w ww .j a v a2s.  c  o m
        ps = con.prepareStatement("insert into EventException "
                + "(eventexception_parent_id, eventexception_date, eventexception_usercreate) "
                + "values (?, ?, " + editor.getObmId() + ")");
        for (Date exd : ev.getRecurrence().getExceptions()) {
            ps.setInt(1, id.getObmId());
            ps.setTimestamp(2, new Timestamp(exd.getTime()));
            ps.addBatch();
        }
        ps.executeBatch();
    } finally {
        obmHelper.cleanup(null, ps, null);
    }
}

From source file:org.jamwiki.db.CacheQueryHandler.java

/**
 *
 *///from   w ww .j  av  a 2 s.co m
@Override
public void insertTopicVersions(List<TopicVersion> topicVersions) {
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    boolean useBatch = (topicVersions.size() > 1);
    try {
        conn = DatabaseConnection.getConnection();
        if (!this.autoIncrementPrimaryKeys()) {
            stmt = conn.prepareStatement(STATEMENT_INSERT_TOPIC_VERSION);
        } else if (useBatch) {
            // generated keys don't work in batch mode
            stmt = conn.prepareStatement(STATEMENT_INSERT_TOPIC_VERSION_AUTO_INCREMENT);
        } else {
            stmt = conn.prepareStatement(STATEMENT_INSERT_TOPIC_VERSION_AUTO_INCREMENT,
                    Statement.RETURN_GENERATED_KEYS);
        }
        int topicVersionId = -1;
        if (!this.autoIncrementPrimaryKeys() || useBatch) {
            // manually retrieve next topic version id when using batch
            // mode or when the database doesn't support generated keys.
            topicVersionId = DatabaseConnection.executeSequenceQuery(STATEMENT_SELECT_TOPIC_VERSION_SEQUENCE);
        }
        for (TopicVersion topicVersion : topicVersions) {
            if (!this.autoIncrementPrimaryKeys() || useBatch) {
                // FIXME - if two threads update the database simultaneously then
                // it is possible that this code could set the topic version ID
                // to a value that is different from what the database ends up
                // using.
                topicVersion.setTopicVersionId(topicVersionId++);
            }
            StringReader sr = null;
            try {
                int index = 1;
                stmt.setInt(index++, topicVersion.getTopicVersionId());
                if (topicVersion.getEditDate() == null) {
                    topicVersion.setEditDate(new Timestamp(System.currentTimeMillis()));
                }
                stmt.setInt(index++, topicVersion.getTopicId());
                stmt.setString(index++, topicVersion.getEditComment());
                //pass the content into a stream to be passed to Cach
                sr = new StringReader(topicVersion.getVersionContent());
                stmt.setCharacterStream(index++, sr, topicVersion.getVersionContent().length());
                if (topicVersion.getAuthorId() == null) {
                    stmt.setNull(index++, Types.INTEGER);
                } else {
                    stmt.setInt(index++, topicVersion.getAuthorId());
                }
                stmt.setInt(index++, topicVersion.getEditType());
                stmt.setString(index++, topicVersion.getAuthorDisplay());
                stmt.setTimestamp(index++, topicVersion.getEditDate());
                if (topicVersion.getPreviousTopicVersionId() == null) {
                    stmt.setNull(index++, Types.INTEGER);
                } else {
                    stmt.setInt(index++, topicVersion.getPreviousTopicVersionId());
                }
                stmt.setInt(index++, topicVersion.getCharactersChanged());
                stmt.setString(index++, topicVersion.getVersionParamString());
            } finally {
                if (sr != null) {
                    sr.close();
                }
            }
            if (useBatch) {
                stmt.addBatch();
            } else {
                stmt.executeUpdate();
            }
            if (this.autoIncrementPrimaryKeys() && !useBatch) {
                rs = stmt.getGeneratedKeys();
                if (!rs.next()) {
                    throw new SQLException("Unable to determine auto-generated ID for database record");
                }
                topicVersion.setTopicVersionId(rs.getInt(1));
            }
        }
        if (useBatch) {
            stmt.executeBatch();
        }
    } catch (SQLException e) {
        throw new UncategorizedSQLException("insertTopicVersions", null, e);
    } finally {
        DatabaseConnection.closeConnection(conn, stmt, rs);
    }
}

From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java

@Override
public void update(final OpenbareRuimte origineel, final OpenbareRuimte mutation) throws DAOException {
    try {//from www .j ava  2 s .c  o  m
        jdbcTemplate.update(new PreparedStatementCreator() {
            @Override
            public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                PreparedStatement ps = connection.prepareStatement("update bag_openbare_ruimte set"
                        + " aanduiding_record_inactief = ?," + " aanduiding_record_correctie = ?,"
                        + " openbare_ruimte_naam = ?," + " officieel = ?,"
                        + " einddatum_tijdvak_geldigheid = ?," + " in_onderzoek = ?,"
                        + " openbare_ruimte_type = ?," + " bron_documentdatum = ?,"
                        + " bron_documentnummer = ?," + " openbareruimte_status = ?,"
                        + " bag_woonplaats_id = ?," + " verkorte_openbare_ruimte_naam = ?"
                        + " where bag_openbare_ruimte_id = ?" + " and aanduiding_record_correctie = ?"
                        + " and begindatum_tijdvak_geldigheid = ?");
                ps.setInt(1, mutation.getAanduidingRecordInactief().ordinal());
                ps.setLong(2, mutation.getAanduidingRecordCorrectie());
                ps.setString(3, mutation.getOpenbareRuimteNaam());
                ps.setInt(4, mutation.getOfficieel().ordinal());
                if (mutation.getEinddatumTijdvakGeldigheid() == null)
                    ps.setNull(5, Types.TIMESTAMP);
                else
                    ps.setTimestamp(5, new Timestamp(mutation.getEinddatumTijdvakGeldigheid().getTime()));
                ps.setInt(6, mutation.getInOnderzoek().ordinal());
                ps.setInt(7, mutation.getOpenbareRuimteType().ordinal());
                ps.setDate(8, new Date(mutation.getDocumentdatum().getTime()));
                ps.setString(9, mutation.getDocumentnummer());
                ps.setInt(10, mutation.getOpenbareruimteStatus().ordinal());
                ps.setLong(11, mutation.getGerelateerdeWoonplaats());
                ps.setString(12, mutation.getVerkorteOpenbareRuimteNaam());
                ps.setLong(13, origineel.getIdentificatie());
                ps.setLong(14, origineel.getAanduidingRecordCorrectie());
                ps.setTimestamp(15, new Timestamp(origineel.getBegindatumTijdvakGeldigheid().getTime()));
                return ps;
            }
        });
    } catch (DataAccessException e) {
        throw new DAOException("Error updating openbare ruimte: " + origineel.getIdentificatie(), e);
    }
}