• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does database need to be explicitly closed? If does, where to close it?

 
Jane Weil
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FBNServer is responsible for two things:
1. create Data instance to opent the databse
<code>
db = new Data("./../classes/suncertify/db/db.db");
</code>
2. create LockManager
The two instances will be passed to factory implementaion, and in turn passed to RemoteData implementation.
When the server is terminated, i think the database will be automatically closed, because db instance is gone. If this is not right, please tell me where to close the database?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well there are two trains of thought. In one there is only the command line server, so Ctrl-C will close the server. This of course means that the db.db file is now closed, so you really wouldn't have to close the database in code.
Now the second, which some people disaggree with, has to do with a server GUI, some people, like myslef, created a GUI for the server. And it has a stop server type button or menu option, when this is selected you would then call lock(-1) then close on the database.
You get to choice which approach you like better.
Hope that helps
Mark
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it OK to have implemented close() in Data, even if you're not creating a UI for the server? My close() just sets a flag that is checked by all other Data methods.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic