Is it efficient to query \ update the database on every transaction: Java application
I am developing a realtime book management system in java. So I need to save all users, workbooks, transactions in the database (3 table users, workbooks, transactions). For this I have implemented JDBC.
So, I would like to know which one is the best among
1) Query and update the database all the time, let's say I have to authenticate a user from usertable or query a book from a table of books
OR
2) First query the database after starting the application and store the corresponding tables in a Hashset and iterate the HashSet while updating or query and update all the Hashsets in the database at the end of execution.
source to share
flush()
...
The answer to your question is that it depends on many factors. In general, you want to avoid hacking the database, so the size and volume of database transactions needs to be built around it.
source to share