my dog learned polymorphism*
The moose likes JDBC and the fly likes JDBC vs Serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC vs Serialization" Watch "JDBC vs Serialization" New topic
Author

JDBC vs Serialization

sridhar ponnusamy
Greenhorn

Joined: Sep 07, 2008
Posts: 19
hi greeting,

For creating google suggestion kind of functionality ( on key press retrive a list of results) :
1) query the SQL table and fetching the records(using JDBC) every time based on key press.
2) fetch the records made to objects , put in a list and serialized already. on key press deserialize that list, manipulate the list(check for startswith()) and showing the results.

which approach is best

thanks in advance
Sridhar
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

I don't understand your question. Why would you want to user serialization here?

Just get the results into a JDBC result set, and load them into memory. Are there too many for memory?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Querying the DB everytime is in fact faster and less memory hogging.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Querying the database on ever character change does sound like it might need some sort of caching mechanism, especially if you need some sort of expiry mechanism and more control over what is cached. Of course, as with any potential performance problem try it first, see if you actually have a problem. Serialization is not likely to be a good choice, because its limited and the extra persistance step is probably going to be slower than going to the DB every time. I'd also suspect this may need to be asynchronous; it's likely to drive users up the wall if they have to wait for the applciation to respond before entering another character.

Have a google for "java caches" there are a whole bunch of them out there that might suit your needs.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sridhar ponnusamy
Greenhorn

Joined: Sep 07, 2008
Posts: 19
thank you very much for all replies. Now i got an idea.....
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Bauke Scholtz wrote:Querying the DB everytime is in fact faster and less memory hogging.


True iff your searching mechanism is optimized.

For systems that don't have a search tool and allow queries directly against the database using things like wildcard values, searches could be incredibly slow. Granted, you wouldn't want to cache/store every wild card either.


My Blog: Down Home Country Coding with Scott Selikoff
 
 
subject: JDBC vs Serialization