Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
sirtimdadiryara
Posts: 22
Registered: ‎05-14-2012
My Device: bold 9700
My Carrier: vodafone
Accepted Solution

Blackberry Java Sqlite Many Record Inserting

How can I insert many rows(~100k) on sqlite database for blackberry java app.? I tried this code:

Database d1;Statement st;

URI dbURI1
= URI.create("file:///SDCard/xxx.db")  if(DatabaseFactory.exists(dbURI1)){
    d1
=DatabaseFactory.open(dbURI1);}else{
    d1
=DatabaseFactory.create(dbURI1);
    st
= d1.createStatement("Insert into..................(for 100 k rows)");

    st
.prepare();
    st
.execute();
    st
.close();}



Eclipse started to be extreme slow and I couldn't debug it.

This is ok but the problem is eclipse is so slow and doesn't allow me to debug. By this way I need to add 100k rows. Do you know any other efficient way?

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Blackberry Java Sqlite Many Record Inserting

welcome to the support forums.

do you execute this on a separate thread? all blocking operations should be done off the event thread.

100k sounds like quite a huge number, but as long as the code compiles...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
sirtimdadiryara
Posts: 22
Registered: ‎05-14-2012
My Device: bold 9700
My Carrier: vodafone

Re: Blackberry Java Sqlite Many Record Inserting

Thak=nk you for your interest.I tried this but again I couldn't debug it.

 

st = d1.createStatement("insert into e2t(xx,yyy) values ('aaa','b.');");st.prepare();st.execute();st.close();
st = d1.createStatement("insert into e2t(xx,yyy) values ('a','ibbb.');");st.prepare();st.execute();st.close();
st = d1.createStatement("insert into e2t(xx,yyy) values ('aa','bb');");st.prepare();st.execute();st.close();

.

.

.

for 100k rows.

Please use plain text.
Contributor
sirtimdadiryara
Posts: 22
Registered: ‎05-14-2012
My Device: bold 9700
My Carrier: vodafone

Re: Blackberry Java Sqlite Many Record Inserting

Any idea?

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold
My Carrier: Vodafone

Re: Blackberry Java Sqlite Many Record Inserting

Hi,

 

I have done something similar and my approch is to store all the sql lines in a sql file and

read the lines from the file.

 

Step-1 Declare a file with all your sql statements.

Step -2 Read the file and insert into DB

 

While inserting it is always better to show a Please Wait dialog.....

 

Rabi

 

Please use plain text.
Contributor
sirtimdadiryara
Posts: 22
Registered: ‎05-14-2012
My Device: bold 9700
My Carrier: vodafone

Re: Blackberry Java Sqlite Many Record Inserting

Hi ,

Thank you I think this is a good way but how can I store .txt files ? In sdcard? if it is how can I save in sdcard?

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold
My Carrier: Vodafone

Re: Blackberry Java Sqlite Many Record Inserting

Hi,

 

You can always include any file as a resource in your project.

 

If you are using eclipse , you can store this in  /res folder

 

Cheers

Rabi Ray

Please use plain text.
Contributor
sirtimdadiryara
Posts: 22
Registered: ‎05-14-2012
My Device: bold 9700
My Carrier: vodafone

Re: Blackberry Java Sqlite Many Record Inserting

:smileyhappy: last question path : res/sss.txt ?

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold
My Carrier: Vodafone

Re: Blackberry Java Sqlite Many Record Inserting

Hi,

 

Yes you can store like that or may create folder under res and store all your sql files.

 

What i have done is 

/res/files/abc.sql

 

and in code to access this use  "/files/abc.sql"

 

Rabi

Please use plain text.
Contributor
Oloruntoba
Posts: 22
Registered: ‎05-04-2012
My Device: BlackBerry Torch 9800
My Carrier: MTN Nigeria

Re: Blackberry Java Sqlite Many Record Inserting

Hi,

I'm facing a similar problem and would like to try out the solution provided here unfortunately i will need with reading from the sql file. Please help with how the contents will look like and how to read them. Thank you
Please use plain text.