diff --git a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java index 7a8ab72e8..e12f0b91a 100644 --- a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java +++ b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcPostgresqlDAO.java @@ -13,6 +13,7 @@ package org.openhab.persistence.jdbc.internal.db; import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.List; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -167,6 +168,22 @@ public class JdbcPostgresqlDAO extends JdbcBaseDAO { } } + @Override + public void doStoreItemValue(Item item, State itemState, ItemVO vo, ZonedDateTime date) throws JdbcSQLException { + ItemVO storedVO = storeItemValueProvider(item, itemState, vo); + String sql = StringUtilsExt.replaceArrayMerge(sqlInsertItemValue, + new String[] { "#tableName#", "#dbType#", "#tablePrimaryValue#" }, + new String[] { storedVO.getTableName(), storedVO.getDbType(), "?" }); + java.sql.Timestamp timestamp = new java.sql.Timestamp(date.toInstant().toEpochMilli()); + Object[] params = { timestamp, storedVO.getValue() }; + logger.debug("JDBC::doStoreItemValue sql={} timestamp={} value='{}'", sql, timestamp, storedVO.getValue()); + try { + Yank.execute(sql, params); + } catch (YankSQLException e) { + throw new JdbcSQLException(e); + } + } + /**************************** * SQL generation Providers * ****************************/