• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is Caching ?

 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dot.net guys said they are using Caching tecniques in database access.In dot net Retrieve all data from particular table or Database into temp memory at a time, this more fast.

However in java how we are achieving this techniques.
my knowledge
1.Using CachedRowSet
2.Using hibernate

please tell me which technique?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In memory caching is just moving data from your database into memory. The simplest way to do it is to copy the contents of a ResultSet into a Collection. Of the two techniques you mention a CachedRowSet is pretty much just that. Hibernate on the other hand is not a caching mechanism, it is an Object Relational Mapping tool that includes various different types of cache. The need for caching alone is not a reason to use it.
 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
In memory caching is just moving data from your database into memory. The simplest way to do it is to copy the contents of a ResultSet into a Collection. Of the two techniques you mention a CachedRowSet is pretty much just that. Hibernate on the other hand is not a caching mechanism, it is an Object Relational Mapping tool that includes various different types of cache. The need for caching alone is not a reason to use it.


But Copying all table values into arraylist is very slow compared to direct access of database right?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. In most JDBC applications the bottleneck will be the connection to the database, not what is going on in memory. It is a common pattern to open a ResultSet, iterate through it copying each row into another data structure then close the ResultSet.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kalees waran:


But Copying all table values into arraylist is very slow compared to direct access of database right?

No. The arraylist is just memory access. The database involves both network traffic (if on a different machine) and file system I/O.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic