I am trying to insert some rows using a prepare-bind statement. One of the columns is of type TIMESTAMP
. How do I bind the variable for this column with the current epoch time?
I have the following table:
CREATE TABLE orders {
user_id TEXT,
order_time TIMESTAMP,
order_id UUID DEFAULT gen_random_uuid(),
order_details TEXT,
PRIMARY KEY (user_id, order_time DESC, order_id),
FOREIGN KEY (user_id) REFERENCES %s (user_id)
);
I have the following prepare statement code:
String stmt = "INSERT INTO orders " +
"(user_id, order_time, order_details) " +
"VALUES (?, ?, ?);"
PreparedStatement p = connection.prepareStatement(stmt);
Now I am trying to bind the current epoch time System.currentTimeMillis()
to variable 2 in this statement. How should I do that?