• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching Database Rows

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wondering if there is any built-in support of caching database rows in JDBC. Currently, if there is some rows to be accessed repeatedly, to reduce the number of SQL calls, I will manually create a Map containing the rows with the Map's key=PK of the table. But maintaining the cache manually looks tedious so just want to know if JDBC already providing help in this area.

Thx
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alec,
JDBC doesn't provide caching built in. The database itself does caching, but then you still have to make a call to the database tier.

Your custom cache is a good way to go. You could do it as a wrapper around JDBC so all the code is in one place.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alec,

you can opt for CachedRowset, It is basically a disconnection rowset

Shailesh
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have cached ResultSets as arrays: Object[][].

One advantage of this approach is that I also have an API that allows you to easily query and sort the array that is in cache (A limited sql syntax but still very handy).



For more info go to http://www.fdsapi.com. There are a couple powerpoints to the left that discuss ArraySQL. I also have a class called ResultSetConverter that puts a ResultSet into an Object[][].
[ May 26, 2005: Message edited by: steve souza ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic