java.sql.SQLException: near "ON": syntax error -
hey guys have scoured many other answers , still unable figure out problem.
statement.executeupdate("create table if not exists recentlywatched (filename string not null, filelocation string, viewcount integer, primary key (filename))"); class.forname("org.sqlite.jdbc"); connection = drivermanager.getconnection("jdbc:sqlite:media.db"); statement = connection.createstatement(); statement.executeupdate("insert recentlywatched (filename, filelocation, viewcount) values ('" + filename + "', '" + filelocation + "', 0) on duplicate key update viewcount = '1'");
i have tried numerous ways resolve issue , @ loss whenever try insert record "java.sql.sqlexception: near "on": syntax error".
update
final code looked
statement.executeupdate("insert or ignore recentlywatched (filename, filelocation, viewcount) values ('" + filename + "', '" + filelocation + "', 0)"); statement.executeupdate("update recentlywatched set viewcount = viewcount + 1 '" + filename + "' filename;");
as 1 can tell class.forname("org.sqlite.jdbc")
using sqlite database doesn't support on duplicate
clause. reason why error.
check this question workaround.
Comments
Post a Comment