0

I sneaked through similar posts, but found no solution. I am getting this Exception when I try to insert values into database

INSERT = "INSERT INTO topnews (sid, headline, metadata, content, image_path,          image_caption , article_id, print_order, art_date, t_stamp) "+  
"VALUES("+_sid+",'"+_headline+"','"+_metadata+"','"+_content+"','"+_imagePath+"','"+_imageCaption+"',"+_articleId+",'"+_printOrder+"','"+_artDate+"','"+_tStamp+"');";
    byte[] i = INSERT.getBytes();
    long l = i.length;
    System.out.println("INSERT STATEMEN"+INSERT);
    _statement = _dbTopNews.createStatement(INSERT);            //EXCEPTION
    _statement.prepare();
    _statement.execute();
    _statement.close();

I tried finding out the length of the query that I am trying to insert. The Exception didn't occur when less than 4000 was inserted. This particular query for which the exception throwed is 4300. The same query is running healthy on Android development environment. I tried inserting the same query via sqlite into database no error occured. I think this is of decent size nothing humongous.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
varunrao321
  • 925
  • 2
  • 10
  • 18

1 Answers1

4

In pre OS 7 the query length limit is 4 KB. You need OS 7 to overcome the limit.

Check the Release Notes - BlackBerry Java SDK - 7.0:

A query can now be up to 1 MB. In BlackBerry Java SDK 6.0, the query length limit was 4 KB

Vit Khudenko
  • 28,288
  • 10
  • 63
  • 91
  • thanks a lot Arhimed, the issue that I have been struggling with for a day. Is it possible to overcome this using parameterized update? and yes for queries with more than 4000characters*1byte the outofmemoryerror occurred. – varunrao321 Nov 02 '11 at 18:54
  • 1
    @Newbie: Sorry, unfortunatelly I have no experience with SQLite on BB (we are still using file storage since RIM added SQLite support only in OS 5 or 6, while we support older OS devices) so I can't help with "whether it's possible to overcome this using parameterized update". You just need to try on your own. – Vit Khudenko Nov 02 '11 at 20:57
  • @arihmed: thank you very much..you saved me from great grief :D – varunrao321 Nov 03 '11 at 04:57