Hello,
I've got database table like this:
CREATE TABLE Device
(
DeviceID BIGINT NOT NULL,
deviceDate DATE NULL,
updatedTimestamp TIMESTAMP NULL,
deviceMode INTEGER NULL,
timer1Start TIME NULL,
timer1Stop TIME NULL,
flowRate INTEGER NULL,
temperature FLOAT NULL
)
And java code like this:
JDBCClient client = JDBCClient.createShared(Vertx.vertx(), new JsonObject()
.put("url", "jdbc:hsqldb:mem:test?shutdown=true")
.put("driver_class", "org.hsqldb.jdbcDriver"));
client.getConnection(res -> {
if (res.succeeded()) {
connection = new AtomicReference<>(res.result());
String query = "INSERT INTO Device (deviceId, deviceDate, updatedTimestamp, deviceMode, timer1Start, timer1Stop, flowRate, temperature) VALUES (?,?,?,?,?,?,?,?);";
Instant date = Instant.now();
JsonArray params = new JsonArray().add(549651730122213L).add(date).add(date).add(1).add(date).add(date).add(1).add(1);
connection.updateWithParams(query, params, res -> {
if (res.succeeded()) {
// ...
}
}
}
java.sql.SQLDataException: data exception: invalid datetime format
How can I pass parameters for TIME, DATE or TIMESTAMP database fields?