I have spent the last hour trying alternate versions of inserting date and time via time stamp into a sql database using java.
Date endDate = new Date();
ptmt.setTimestamp(5, new java.sql.Timestamp(endDate.getTime()));
My create table statement is
CREATE TABLE Location (
UserID varchar(50),
Latitude DOUBLE,
Longitude DOUBLE,
Altitude DOUBLE,
TimeInserted timestamp
);
Are there alternative ways of entering the date.
In my prepared statement I tried to have now() within the string, but it looked for the parameter.
String queryString = "INSERT INTO Location(UserID,Latitude,Longitude,Altitude,TimeInserted) VALUES(?,?,?,?,now());";
however it wasn't happy when searching for the 5th parameter.
Any ideas?
I tried making the table date and managed to insert simply the date - however I need the time to order by.
Thanks
timestamp? Use adatetime.