• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I secure the database to make it robust?

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made several calls to JDBC which spread over a couple of modules.
I wonder, if say the power breaks down, the database will
be in a inconsistent state, How can I ensure this won't happen,
Do I delay the commit to the very last minute?
Thanks
Jack
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The databases (except perhaps the most simple ones, such as MS Access) are designed to protect the data even in case of system failure or power outage. If this happens, the database does what is necessary to get into consistent state after next startup. Everything what was committed is guaranteed to be there, and everything what wasn't committed gets cleaned up.

More advanced databases can usually be even configured to provide protection agains media failure, situation where your hard disk fails. This usually requires some more configuration and doesn't work out of the box automatically. If you were interested into this kind of protection, your best bet would be to consult your database documentation.
 
Paul Clapham
Sheriff
Posts: 21551
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And as a general rule you should commit your transactions as soon as possible, rather than delaying the commit as long as possible. Uncommitted transactions may lead to problems with other applications which are trying to use the same data, and this is a far more likely possibility than a power failure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic