File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes cache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "cache " Watch "cache " New topic


Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
I want to cache the resultset information got by executing a query "Query1". Now when i exceute "Query1" again i want to read from the cache instaed of making a database call again. Do i have to do this explicitly in my application where-in i check in the cache for data if not found then i query the Database or this process is done implicitly.
In either case, explicit or implicit loading,the cache can only serve the purpose only if the "Query1 " is exceuted for the 2nd time if not, my cache is useless (Hope iam correct). So what is the better way of doing things and when to go for cache (Will it be helpful in this scenario ??)
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hi Babu,
I don't know what databases you are planning on working with (since I saw no mention of that in your post), but I know that this is the default behaviour with the Oracle database that I work with (version on SUN [sparc] Solaris 7).
The database has a cache where it keeps query results. So the second time you execute the same query, if the results are still in the database cache, then the data in the cache is what is returned.
I would imagine that other databases behave the same way.
So why would you want to implement this behaviour yourself? Even if you insisted on implementing this behaviour yourself, my guess is that the database's implementation is probably much better than what yours would be -- don't you think?
Hope this has helped you.
Good Luck,
I agree. Here's the link:
subject: cache
It's not a secret anymore!