• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about method close

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,
What do you think about it?
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
right... sorry again, I'm doing the beta exam and our DB interface does not have any close() method...
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Michael Morris,
Thanks, I did it. I like your design!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic