达到最大尺寸为数据库编译-SQL语句缓存 [英] Reached MAX size for compiled-sql statement cache for database
问题描述
我的code是
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);
一个警告显示在日志猫
a warning is shown in the 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
如何解决它。请帮助
How to resolve it. Please Help
推荐答案
看例子8-3和8-4 这里一>
Look at examples 8-3 and 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());
}
}
下面是一些的code例8-3的亮点:
Here are some of the highlights of the code in Example 8-3:
例8-4显示了如何使用execSQL方法。
示例8-4。使用execSQL方法
Example 8-4 shows you how to use the execSQL method.
Example 8-4. Using the execSQL method
/**
* 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) {
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变量来代替。
The message is asking you to make parameters use sql variables instead of sql literals.
每个SQL查询进行分析,生成计划,并存储在SQL语句缓存。
Each sql query is parsed, plans are generated, and stored in a sql statement cache.
查询具有相同的文字是从缓存中提取。
Queries which have the same text are fetched from the cache.
--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)
查询具有不同的文本(包括文字)不能在缓存中找到,并(无用)添加进去。
Queries which have different text (including literals) cannot be found in the cache and are (uselessly) added to it.
--Three Queries.
SELECT * FROM Customers WHERE Id = 3
SELECT * FROM Customers WHERE Id = 4
SELECT * FROM Customers WHERE Id = 5
这篇关于达到最大尺寸为数据库编译-SQL语句缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!