Moving to... JDBC for now. Clearly not testing, and we don't know if you're using an ORM. Not sure if this should be in beginning Java, if you're just having a problem making a hash table, or in Other Open Source Products if you plan on using an existing cache solution.
How to make a hash table? Probably use entity ID as the key, and use the entity as the value. Then look up the results from there instead of the DB.
Though you could use simple Collections to cache data there are far more sophisticated solutions out there. Have a google for "java cache" and you'll see a whole bunch of products. Also, ORMs come with levels of caching. you might consider this too.
Rajendra Prakash wrote:Instead of Retrieving database tables from DB, how can i store it in cache.
I want to improve the performance.
Better use some open source caching framework like JBoss cache. when the application starts up. retrieve everything from DB and put it in cache.When ever there is a database update/insert happens update cache too.
Paul Sturrock wrote:
How does it pick up updates made by other processes?
Some databases have a mechanism for this. For example Oracle (10g and higher) allows you to register for notifications about DML and DDL changes to tables, or even queries (11g). It's called Database Change Notification, if you want to look it up.