开发者

Reached max size for compiled sql statement cache for database problem related to query?

friends,

i have written following sqlite insert statement which seems to be wrong. before inserting row i am checking if record exists then dont insert(ATM data is more than 600 records)

Reached max size for compiled sql statement cache for database.no space for this sql statement in cache.select 1 from atm where atmid=251 please change your sql statment to use "?" for bindargs, instead of

public void addAtm(ATM atm)
    {

db.execSQL("INSERT INTO " + AtmsTable.NAME + 
        "(" +AtmsTable.COL_ID + ","
        +AtmsTable.COL_BankID +"," 
        + AtmsTable.COL_BankNAME+","
        + AtmsTable.COL_BankPhone+","
        + AtmsTable.COL_BankAddress+","
        + AtmsTable.COL_BankCoordinates+","
        + AtmsTable.COL_BankCi开发者_如何学JAVAty+","
        + AtmsTable.COL_BankWebaddress+") Values (" 
        +atm.getAtmID()+","
        +atm.getBankID()
        + ",'" + atm.getBankName().trim()
        +"','" + atm.getPhone()
        +"','" + atm.getAddress()
        +"','" + atm.getCoordinates()
        +"','" + atm.getCity()
        +"','" + atm.getWebAddress()+ "');");

}

and

public boolean atmExists(int atmId)
    {
        OpenIfNotOpened();
         Cursor cursor = db.rawQuery("select 1 from " + AtmsTable.NAME  +" where " + AtmsTable.COL_ID + "=" + atmId,null);
               boolean exists = (cursor.getCount() > 0);
               cursor.close();
               return exists;
    }

and i am getting following error message

any help would be appreciated.


public void execSQL (String sql)

Since: API Level 1 Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data. It has no means to return any data (such as the number of affected rows). Instead, you're encouraged to use insert(String, String, ContentValues), update(String, ContentValues, String, String[]), et al, when possible.

just use:

ContentValues vals = new ContentValues();
vals.put(AtmsTable.COL_BankID, atm.getBankID());
vals.put(AtmsTable.COL_BankNAME, atm.getBankName().trim());
/...
if(db.update(AtmsTable.NAME, vals, AtmsTable.COL_ID + "=?", new String[]{Integer.toString(atm.getAtmID())}) == 0){
  vals.put(AtmsTable.COL_ID, atm.getAtmID());
  db.insert(AtmsTable.NAME, null, vals);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜