According to this page, date
is a MS-Access keyword. Reformulating your query to something like so should do the trick:
String sql = "insert into accounts (title , [date] , amount) values ('titlexx' , '21-01-2014' , 26000) ";
Question
I am using Access 2010 and java 6, I am trying to execute this query but it is giving me an error, here is my code:
String sql = "insert into accounts (title , date , amount) values ('titlexx' , '21-01-2014' , 26000) ";
getConnection().createStatement().executeUpdate(sql);
The error I am getting is this:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
I don't know where I am going wrong guys.
Solution
According to this page, date
is a MS-Access keyword. Reformulating your query to something like so should do the trick:
String sql = "insert into accounts (title , [date] , amount) values ('titlexx' , '21-01-2014' , 26000) ";
OTHER TIPS
String sql = "insert into accounts (title , date , amount) values (' "+"titlexx"+" ' , ' "+"21-01-2014"+" ' , 26000) "; --if title and date are string.