I have a MySQL database to which I connect via java program. In 'locations' table I have a 'ExpDate' column of type 'Date'. I cannot write a date back as, I guess there is a format clash. Code:
resultSet = statement.executeQuery("SELECT * FROM locations WHERE LocID = '" + oldLocation + "'");
resultSet.first(); // Position to row.
Date oldLocExpDate = resultSet.getDate("ExpDate");
statement.executeUpdate("UPDATE locations SET 'ExpDate' = '" + oldLocExpDate + "' WHERE LocID = '" + newLocation + "'");
I get exception saying there is something wrong with the SQL syntax. I have also tried to get date input as string, but that didn't work.
How do I rewrite the last line of code so it writes the date into the database.