I am using the GridDB Java Client API to insert records into a container that contains a `TIMESTAMP` column.
Environment
* GridDB Cloud
* GridDB Java Client API: ``
* Java: ``
* Container Type: Collection
Container Schema
CREATE TABLE sensor_data (
ts TIMESTAMP,
sensor_id STRING,
temperature DOUBLE,
PRIMARY KEY(ts)
);
Java Code
ContainerInfo containerInfo = store.getContainerInfo("sensor_data");
Container, Row> container = store.getContainer("sensor_data");
Row row = container.createRow();
row.setTimestamp(0, Instant.now());
row.setString(1, "sensor-01");
row.setDouble(2, 26.5);
container.put(row);
Error
The exception occurs when executing `container.put(row)`:
com.toshiba.mwcloud.gs.GSException:
[145002:GS_ERROR_DATA_TYPE_MISMATCH]
Cannot assign value to TIMESTAMP column
Column `ts` is defined as `TIMESTAMP`, so I expected the value returned by `Instant.now()` to be accepted. However, the API throws a data type mismatch error.
I also verified that column index `0` corresponds to the `TIMESTAMP` column, the container schema is correctly created, the error disappears if the timestamp field is not assigned and other fields (`STRING` and `DOUBLE`) are inserted successfully.
I also found examples that use `java.util.Date` or `java.sql.Timestamp`, but I could not find clear documentation about support for `java.time.Instant`.
Question
Does the GridDB Java API support inserting `java.time.Instant` directly into a `TIMESTAMP` column? If not, what is the recommended approach? Should the value be converted before insertion, for example:
row.setTimestamp(
0,
java.sql.Timestamp.from(Instant.now())
);
or should `java.util.Date` be used instead?
I would like to understand which Java timestamp types are officially supported by `Row.setTimestamp()` and how `TIMESTAMP` columns should be populated when using the Java 8+ Date/Time API.