android.database.sqlite.SQLiteException:near“s”:语法错误(代码1):,

时间:2016-04-17 09:09:54

标签: android android-sqlite

android.database.sqlite.SQLiteException:near“s”:语法错误(代码1):,同时编译:INSERT OR REPLACE INTO电影(backdrop_path,id,original_language,orginal_title,overview,poster_path,title,popular,adult ,视频,vote_avg,vote_count,RELEASE_DATE,最喜欢的) VALUES('/tbhdm8UJAb4ViCTsulYFL3lxMCd.jpg','76341','en','null','在我们这个星球最远的地方设置一个世界末日的故事,在一个人类被打破的荒凉沙漠景观中,大多数人都疯狂战斗在这个世界上,有两个反叛者在奔跑,他们可能能够恢复秩序.Max,一个行动的人和一个言语少的人,在失去他的妻子之后寻求安心。混乱之后的孩子.Furiosa,一个行动的女人和一个相信她生存之路的女人,如果她能穿越沙漠回到童年的家园,她就可以实现。','/ kqjL17yufvn9OVLyXYpvtyrFfak.jpg', 'Mad Max:Fury Road','19.132107','false','false','7','4359',' - 546474976','false' );             在android.database.sqlite.SQLiteConnection.nativePrepareStatement(本机方法)             在android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)

3 个答案:

答案 0 :(得分:3)

你有一个字符串,并没有逃避它。为避免这种情况,请不要像这样直接插入 - 始终使用绑定变量。这也将避免SQL注入错误,我确信你的代码基于此。

答案 1 :(得分:3)

您正试图插入There's Max,其中(')应该像[{1}}

一样进行转义

答案 2 :(得分:2)

您的错误很可能出在此输入中:

An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order. There's Max, a man of action and a man of few words, who seeks peace of mind following the loss of his wife and child in the aftermath of the chaos. And Furiosa, a woman of action and a woman who believes her path to survival may be achieved if she can make it across the desert back to her childhood homeland.

... There's Max

部分有一个未转义的单引号

当SQLite尝试执行此记录的插入时,它会以该单引号结束,之后,它会尝试处理s Max, a man of action ....

要解决这个问题,请逃离'如此:\'

你必须在SQLite中转义你的角色,以避免像这些和SQL注入这样的错误。