Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ private void initSqlQueries() {
private void initSqlTypes() {
logger.debug("JDBC::initSqlTypes: Initialize the type array");
sqlTypes.put("tablePrimaryValue", "strftime('%Y-%m-%d %H:%M:%f' , 'now' , 'localtime')");
sqlTypes.put("tablePrimaryValueFormated",
"strftime('%Y-%m-%d %H:%M:%S' , substr(?, 0, 11), 'unixepoch', 'localtime') || '.' || substr(?, 11, 3)");
}

/**
Expand Down Expand Up @@ -130,9 +132,11 @@ public void doStoreItemValue(Item item, State itemState, ItemVO vo, ZonedDateTim
ItemVO storedVO = storeItemValueProvider(item, itemState, vo);
String sql = StringUtilsExt.replaceArrayMerge(sqlInsertItemValue,
new String[] { "#tableName#", "#dbType#", "#tablePrimaryValue#" },
new String[] { formattedIdentifier(storedVO.getTableName()), storedVO.getDbType(), "?" });
new String[] { formattedIdentifier(storedVO.getTableName()), storedVO.getDbType(),
sqlTypes.get("tablePrimaryValueParsed") });

java.sql.Timestamp timestamp = new java.sql.Timestamp(date.toInstant().toEpochMilli());
Object[] params = { timestamp, storedVO.getValue() };
Object[] params = { timestamp, timestamp, storedVO.getValue() };
logger.debug("JDBC::doStoreItemValue sql={} timestamp={} value='{}'", sql, timestamp, storedVO.getValue());
try {
Yank.execute(sql, params);
Expand Down