【发布时间】:2017-02-26 19:07:04
【问题描述】:
您好,我正在尝试在我的 sqlite 数据库中插入值,但是对于字节数组的最后一个值异常,我得到“无法识别的令牌”。这是代码:
public void insertImage(String userName, String userMob, String meterReading, String readingAddress, String readingRemark, String readingDate , byte[] imageBytes) {
try {
mDb.execSQL("INSERT INTO " + IMAGES_TABLE +"(" + USER_NAME + ", " + USER_MOB + ", " + METER_READING_TEXT + ", " + READING_REMARKS + ", " + READING_DATE + ", " + IMAGE + ")" +
" VALUES (" + userName + ", " + userMob + ", " + meterReading + ", " + readingAddress + ", " + readingRemark + ", " + readingDate + ", " + imageBytes + ");");
}
catch (Exception ex){
ex.printStackTrace();
Log.e("-----","dasdasdas");
}
}
【问题讨论】:
-
使用参数化查询。这样你就不会遇到这样的问题了。
-
字符串必须在 SQL 中被引用。
标签: java android sql database sqlite