milo
(M)
March 26, 2024, 7:27am
1
Hello,
I getting currently this strange warning in my logs…
JDBC::store: Unable to store item
Error: 1292-22007: Incorrect datetime value: '1970-01-01 01:00:00' for column `openhabian`.`item0207`.`value` at row 1
If i check the item via rest i getting this value back
{
"link": "[url]/rest/items/dwdweatherwarningstuttgart_effective2",
"state": "1970-01-01T00:00:00.000+0000",
"stateDescription": {
"pattern": "%1$tT, %1$td.%1$tm.%1$tY",
"readOnly": false,
"options": []
},
"metadata": {
"semantics": {
"value": "Point_Status",
"config": {
"isPointOf": "group_weatherstation"
}
}
},
"editable": false,
"type": "DateTime",
"name": "dwdweatherwarningstuttgart_effective2",
"label": "Issued at",
"category": "dwd",
"tags": [
"Status"
],
"groupNames": [
"group_weatherstation"
]
}
milo
(M)
March 31, 2024, 7:50am
2
Is there any help for this one?
splatch
(Łukasz Dywicki)
March 31, 2024, 7:26pm
3
If you can, please inspect database and type of value
column. Sometimes when item type is redefined schema retains old type causing such errors.
milo
(M)
March 31, 2024, 7:54pm
4
See attached the definition
…
No value stored so far
splatch
(Łukasz Dywicki)
March 31, 2024, 8:43pm
5
It looks good, you have datetime item and timestamp type for value column, which is valid for temporal data. However it does fail to store date time value. Can you share which database and which OH version you use? From error code I presume MySQL. If that’s true value you have might not fit timestamp type, because mysql will prefer numeric representation (epoch/unix timestamp). You either have to convert it (through modification of JDBC service config) or change database column type to one which will accept above string. Here is some note from stack overflow: sql timestamp - MySQL 1292 Incorrect datetime value - Stack Overflow
milo
(M)
April 1, 2024, 6:30am
6
Hello,
this is how i update the item…
items.getItem("dwdweatherwarning_expires3").postUpdate(0);
is this wrong?
splatch
(Łukasz Dywicki)
April 1, 2024, 10:09pm
7
It is ok, however this 0
is being then translated into DateTime
and then, it needs to be translated into database value. Issue you observe in logs is caused by last stage - value which is generated by insert into
statement is not accepted by database engine. So you need to tune that part.
I am not quite sure how to do it properly as I did not need to customize SQL statements in jdbc config since … ever?
milo
(M)
April 2, 2024, 1:51am
8
Found this bug report on GitHub
opened 12:23PM - 04 Oct 23 UTC
bug
## Expected Behaviour
When a DateTime item is persisted, it should persist :-)
…
## Current Behaviour
The reason I run into this issue is when I tried to persist a DateTime item and the value cannot be saved if the time is smaller than the time zone, in addition on a restart none of the persisted values are not restored.
## Possible Solution
When creating a new DateTime persisted item set the value field to DateTime instead of TimeStamp. I've manually changed my database table fields and the system works as expected.

## Steps to Reproduce (for Bugs)
Create a DateTime items and set a time smaller than the Time Zone. In my case I'm +7 so 00:00 to 07:00 results in the following error:
```
2023-10-04 18:30:30.323 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::storeItemValue: item=ROBSched1StartTim (Type=DateTimeItem, State=1970-01-01T03:00:00.000+0700, Label=Start time, Category=time, Tags=[Measurement, Duration], Groups=[gRobotLIV, gVacumeRU, PersistY]) state=1970-01-01T03:00:00.000+0700 date=null
2023-10-04 18:30:30.323 [DEBUG] [persistence.jdbc.internal.dto.ItemVO] - JDBC:ItemVO tableName=robsched1starttim_3757; newTableName=null;
2023-10-04 18:30:30.323 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::storeItemValueProvider: item 'ROBSched1StartTim' as Type 'DATETIMEITEM' in 'robsched1starttim_3757' with state '1970-01-01T03:00:00.000+0700'
2023-10-04 18:30:30.324 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::storeItemValueProvider: itemState: '1970-01-01T03:00:00.000+0700'
2023-10-04 18:30:30.324 [DEBUG] [persistence.jdbc.internal.dto.ItemVO] - JDBC:ItemVO setValueTypes dbType=TIMESTAMP(3); javaType=class java.sql.Timestamp;
2023-10-04 18:30:30.324 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::storeItemValueProvider: DateTimeItem: '1970-01-01 03:00:00.0'
2023-10-04 18:30:30.324 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::doStoreItemValue sql=INSERT INTO robsched1starttim_3757 (time, value) VALUES( NOW(3), ? ) ON DUPLICATE KEY UPDATE VALUE= ? value='1970-01-01 03:00:00.0'
2023-10-04 18:30:30.334 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: Unable to store item
org.openhab.persistence.jdbc.internal.exceptions.JdbcSQLException: Error in SQL query!!!; Data truncation: Incorrect datetime value: '1970-01-01 03:00:00' for column 'value' at row 1 Query: INSERT INTO robsched1starttim_3757 (time, value) VALUES( NOW(3), ? ) ON DUPLICATE KEY UPDATE VALUE= ? Parameters: [1970-01-01 03:00:00.0, 1970-01-01 03:00:00.0]; Pool Name= yank-default; SQL= INSERT INTO robsched1starttim_3757 (time, value) VALUES( NOW(3), ? ) ON DUPLICATE KEY UPDATE VALUE= ?
at org.openhab.persistence.jdbc.internal.db.JdbcBaseDAO.doStoreItemValue(JdbcBaseDAO.java:443) ~[?:?]
at org.openhab.persistence.jdbc.internal.JdbcMapper.storeItemValue(JdbcMapper.java:220) ~[?:?]
at org.openhab.persistence.jdbc.internal.JdbcPersistenceService.internalStore(JdbcPersistenceService.java:162) ~[?:?]
at org.openhab.persistence.jdbc.internal.JdbcPersistenceService.store(JdbcPersistenceService.java:140) ~[?:?]
at org.openhab.core.persistence.internal.PersistenceManager.lambda$7(PersistenceManager.java:170) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
at java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720) ~[?:?]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
at org.openhab.core.persistence.internal.PersistenceManager.lambda$3(PersistenceManager.java:168) ~[?:?]
at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4780) ~[?:?]
at org.openhab.core.persistence.internal.PersistenceManager.handleStateEvent(PersistenceManager.java:165) ~[?:?]
at org.openhab.core.persistence.internal.PersistenceManager.stateChanged(PersistenceManager.java:329) ~[?:?]
at org.openhab.core.items.GenericItem.lambda$1(GenericItem.java:260) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
```
When changing the value field to DateTime the Debug log shows:
```
2023-10-04 18:49:00.175 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::storeItemValue: item=ROBSched1StartTim (Type=DateTimeItem, State=1970-01-01T03:00:00.000+0700, Label=Start time, Category=time, Tags=[Measurement, Duration], Groups=[gRobotLIV, gVacumeRU, PersistY]) state=1970-01-01T03:00:00.000+0700 date=null
2023-10-04 18:49:00.175 [DEBUG] [persistence.jdbc.internal.dto.ItemVO] - JDBC:ItemVO tableName=robsched1starttim_3757; newTableName=null;
2023-10-04 18:49:00.176 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::storeItemValueProvider: item 'ROBSched1StartTim' as Type 'DATETIMEITEM' in 'robsched1starttim_3757' with state '1970-01-01T03:00:00.000+0700'
2023-10-04 18:49:00.176 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::storeItemValueProvider: itemState: '1970-01-01T03:00:00.000+0700'
2023-10-04 18:49:00.176 [DEBUG] [persistence.jdbc.internal.dto.ItemVO] - JDBC:ItemVO setValueTypes dbType=TIMESTAMP(3); javaType=class java.sql.Timestamp;
2023-10-04 18:49:00.176 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::storeItemValueProvider: DateTimeItem: '1970-01-01 03:00:00.0'
2023-10-04 18:49:00.176 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::doStoreItemValue sql=INSERT INTO robsched1starttim_3757 (time, value) VALUES( NOW(3), ? ) ON DUPLICATE KEY UPDATE VALUE= ? value='1970-01-01 03:00:00.0'
```
## Context
Using the DateTime item to set the time for a vacuum scheduler, as the schedule is mostly just after midnight I run into this issue.
## Your Environment
OH 4.0.3 running on a Proxmox VM with Debian 11
MySQL running on a Proxmox VM with Debian 11 and MySQL version 8.0.34 (MySQL Community Server - GPL)
JDBC version 4.0.3 with mysql-connector-j-8.0.33.jar
system
(system)
Closed
May 13, 2024, 5:52pm
9
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.