File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Transferring huge list of strings to service layer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Transferring huge list of strings to service layer" Watch "Transferring huge list of strings to service layer" New topic
Author

Transferring huge list of strings to service layer

Ahsan Bagwan
Ranch Hand

Joined: Oct 05, 2010
Posts: 153
In my data layer, I will be querying my data store to fetch a single column. But the rows will be large enough containing thousands of records.

My JDBC block of code will be something along these lines:



I have been bitten many times before by memory exhaustion errors. I want to avoid that and be in the know of the convention to take care of transfer of humongous list. How would you go about if this was your problem.

One more question that strikes me to be an issue is - Does it justify creating a Java bean when I have only one field?

Mods, don't know if this is more suited to the Java in general forum.
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 761
    
    9
What will you do with those thousands of records after fetching them?
Ahsan Bagwan
Ranch Hand

Joined: Oct 05, 2010
Posts: 153
Send it to the client which is not necessarily a web presentation layer but a normal main method of a class. And when that is done read it one by one.
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 761
    
    9
The nature of the client is important because that determines if it makes sense to retrieve those thousands at all or not. Clients intended to be read by humans should not return more than 100 records at a time because humans won't be able to analyse that volume anyway. Typically one uses the ValueListHandler pattern to implement server side pagination and return the data in smaller chunks. That way you can control scalability by adjusting the page size. Of course this only works if the data can be processed/viewed in chunks.
Ahsan Bagwan
Ranch Hand

Joined: Oct 05, 2010
Posts: 153
It appears to me that I am out of options here as the client should not be able to read records just that it should be transferred to it. I think I might have been kind of vague with the word read. Nonetheless I learned how the pagination is handled in the presentation layer by making use of Value List Handler and for that I am quite grateful.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Transferring huge list of strings to service layer
 
Similar Threads
Working with complex detached object graphs in EJB3 or hibernate in 3-tier architecture
access database with java
Strings "equality"
Problem with querying and one to many relationship..
Lazy loading exception in presentation layer, what's the nicest way to avoid them?