ContentValues values; values = new ContentValues(); values.put(sqlHelper.EMPLOYEE_LPN,JsObj.getString("lpn"));db.update(sqlHelper.EMPLOYEE_table,values,"EMPLOYEE_LPN ='" + JsObj.getString("lpn") + "'",null);
Log Cat中显示警告
08-31 15:19:45.297: WARN/Database(2868): Reached MAX size for compiled-sql statement cache for database /data/data/org.sipdroID.sipua/databases/test.db; i.e.,NO space for this sql statement in cache: SELECT EMPLOYEE_name FROM eyemployee WHERE EMPLOYEE_LPN ='1169162'. Please change your sql statements to use '?' for bindargs,instead of using actual values
如何解决请帮忙
解决方法 看看例子8-3和8-4 here.例8-3.使用更新方法
/** * Update a job in the database. * @param job_ID The job ID of the existing job * @param employer_ID The employer offering the job * @param Title The job Title * @param description The job description */public voID editJob(long job_ID,long employer_ID,String Title,String description) { ContentValues map = new ContentValues(); map.put("employer_ID",employer_ID); map.put("Title",Title); map.put("description",description); String[] whereArgs = new String[]{Long.toString(job_ID)}; try{ getWritableDatabase().update("jobs",map,"_ID=?",whereArgs); } catch (sqlException e) { Log.e("Error writing new job",e.toString()); }}
以下是示例8-3中的代码的一些亮点:
例8-4显示了如何使用execsql方法.
例8-4.使用execsql方法
/** * Update a job in the database. * @param job_ID The job ID of the existing job * @param employer_ID The employer offering the job * @param Title The job Title * @param description The job description */public voID editJob(long job_ID,String description) { String sql = "UPDATE jobs " + "SET employer_ID = ?,"+ " Title = ?,"+ " description = ? "+ "WHERE _ID = ? "; Object[] bindArgs = new Object[]{employer_ID,Title,description,job_ID}; try{ getWritableDatabase().execsql(sql,bindArgs); } catch (sqlException e) { Log.e("Error writing new job",e.toString()); }}
该消息是要求您使用sql变量而不是sql文字的参数.
解析每个SQL查询,生成计划,并存储在SQL语句缓存中.
从缓存中提取具有相同文本的查询.
--One querySELECT * FROM Customers WHERE ID = @1 (@1 = 3)SELECT * FROM Customers WHERE ID = @1 (@1 = 4)SELECT * FROM Customers WHERE ID = @1 (@1 = 5)
在缓存中找不到具有不同文本(包括文字)的查询,并且(无用地)添加了它.
--Three QuerIEs.SELECT * FROM Customers WHERE ID = 3SELECT * FROM Customers WHERE ID = 4SELECT * FROM Customers WHERE ID = 5总结
以上是内存溢出为你收集整理的android – 达到数据库的编译SQL语句高速缓存的MAX大小全部内容,希望文章能够帮你解决android – 达到数据库的编译SQL语句高速缓存的MAX大小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)