• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about method close

 
hao li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since close is public method, If the client code
close the database by calling the method, the server database can not support the other clients.
For my code,I close the database in the server and I do not close database in the client. but method close is public method, do we need to do something on it for the client to close the database?
Thanks,
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was thinking in this way!
Use a SingleTon to open and close the data file. The data file may be opened when the first request from the client comes to the server or during server startup (is not the former logical?). And close the data file during server shut down or when the current active client request count is zero (is not the later logical?).
 
hao li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
the current active client request count is zero
This means that the client who close the database can still access the database if the count is not zero. unless we have a static set in the server to store all connected client...
too complicated?
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I haven't decided on it yet. But it may be like ---- One client accesses the file, reads/writes and the server decides whether the file should be closed now depending on whether any other client is still working on that file. If none, close the file else let it remain opended. Repeat it in a loop till the active client count is zero and when zero close the file.
 
XJ LIN
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
What do you think about it?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My server opens the DB file when it starts up and closes the DB file when it shuts down. A server is a server... Even if no clients are connected, there is no reason to close the DB... Imagine a web server closing a back-end DB because no clients have made a request :roll:
 
XJ LIN
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So why the method close is public?
Some one my use the method to close the database
if he likes.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right... sorry again, I'm doing the beta exam and our DB interface does not have any close() method...
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually what Valentin said is correct. Even though it is public, its purpose is for the server to open and close that database at startup and shutdown.
Just don't have the client call close and you are fine.
Mark
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my design calling close() on a remotely connected client did nothing. Only a server or locally connected client could close() the database.
Michael Morris
 
hao li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Michael Morris and mark.
How do you know it is server call or client call?
make a flag or need a set parameter method for remote database?
 
hao li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Michael Morris,
Thanks, I did it. I like your design!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic