Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 达到数据库的编译SQL语句高速缓存的MAX大小大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的代码
ContentValues values; 
values = new ContentValues();
        values.put(sqlHelper.emploYEE_LPN,jsObj.getString("lpn"));
db.@R_675_9531@e(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.使用更新方法

/**
 * @R_675_9531@e a job in the database.
 * @param @R_200_6186@         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 @R_200_6186@,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(@R_200_6186@)};
    try{
        getWritableDatabase().@R_675_9531@e("jobs",map,"_id=?",whereArgs);
    } catch (sqlException E) {
        Log.e("Error wriTing new job",e.toString());
    }
}

以下是示例8-3中的代码的一些亮点:

例8-4显示了如何使用execsql方法.
例8-4.使用execsql方法

/**
 * @R_675_9531@e a job in the database.
 * @param @R_200_6186@         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 @R_200_6186@,String description) {
    String sql = 
        "@R_675_9531@E jobs " +
        "SET employer_id = ?,"+
        " title = ?,"+
        " description = ? "+
        "WHERE _id = ? ";
    Object[] bindArgs = new Object[]{employer_id,title,description,@R_200_6186@};
    try{
        getWritableDatabase().execsql(sql,bindArgs);
    } catch (sqlException E) {
        Log.e("Error wriTing new job",e.toString());
    }
}

该消息是要求您使用sql变量而不是sql文字的参数.

解析每个SQL查询,生成计划,并存储在sql语句缓存中.

从缓存中提取有相同文本的查询.

--One query
SELECT * 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 = 3
SELECT * FROM Customers WHERE Id = 4
SELECT * FROM Customers WHERE Id = 5

大佬总结

以上是大佬教程为你收集整理的android – 达到数据库的编译SQL语句高速缓存的MAX大小全部内容,希望文章能够帮你解决android – 达到数据库的编译SQL语句高速缓存的MAX大小所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。