-2

I'm trying to insert a date in SQLite database, can anyone help me with the query this is my query:

ResultSet rs = stmt.executeQuery( "INSERT INTO date VALUES (10/10/2020)");

an this is the error that i'm having :

org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (near "30": syntax error)

7
  • The format you have to use is : yyyy-mm-dd Commented May 25, 2017 at 17:41
  • java.sql.SQLException: query does not return ResultSet thats what i had when i used ResultSet rsNote = stmtNote.executeQuery( "INSERT INTO date VALUES (2020-10-10)"); Commented May 25, 2017 at 17:45
  • You shouldn't use executeQuery for insert operation. Use executeUpdate or execute. javaconceptoftheday.com/… Commented May 25, 2017 at 17:49
  • stmtNote.executeUpdate( "INSERT INTO date VALUES (2020-10-10)"); and it added 2000 to the database Commented May 25, 2017 at 18:01
  • Don't get me wrong...but are you really doing any research before asking? You post the error and wait for answer!!! Commented May 25, 2017 at 18:06

1 Answer 1

0

"INSERT INTO date VALUES (2020-10-10)" will insert 2000, as you reported, because 2020-10-10 = 2010-10 = 2000 (this is an integer evaluation). If you want a string, then specify it - "INSERT INTO date VALUES ('2020-10-10')"

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.