on 06-22-2005 9:06 AM
Hello,
I am having a starard application which fetches data from MSSQL Server using this standard code:
CallableStatement cs;
Connection connection;
...
cs = connection.prepareCall("{call " + PROCREQUEST_SP + "(?,?,?)}");
cs.execute();
ResultSet rs = cs.getResultSet();
while (rs.next())
...
Most of the queries the users run are no more than 10,000 records and the code works OK like this.
But, the Database contains more the 7 million records and I would like to enable the user to see all these records if he wants to.
If I enable it at the current code I finally receive java.lang.OutOfMemory Exception. How can I improve my code in order to do this kind of task?
Hello Roy,
Usually for fetching huge data from DB, which the user may scroll through is done in chunks (groups of few hunderds or thousands). For showing it on the UI side we use pagination i.e. user sees only 100 or 1000 records in one screen and then clicks next or page no. to get the other 1000 records.
Hope this helps..
Cheers,
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Roy,
Yes the DB is connected again and only the data chunk asked for is called. eg. if user is on page 2, containing recoreds 1000-2000, and clicks on 3 only records from 2000-3000 should be fetched from the DB. This logic should be taken care by your query.
This saves a lot of Memory,so you wouldn't face MemoryException.
Regards,
Rahul
Hello,
try with scrollable ResultSet - ResultSet.TYPE_SCROLL_INSENSITIVE.
It's able to scroll on results.
Kind regards,
Marcin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roy,
does the user really need 7 million records all at once? Or can you implement some kind of background job that loads the data the user request for (e.g. when the user is scolling in a list, the job gets the next n elements)? What are your settings for heap-size?
bye
Torsten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.