File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes about method close Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "about method close" Watch "about method close" New topic
Author

about method close

hao li
Greenhorn

Joined: Jul 24, 2002
Posts: 21
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

Joined: Jul 05, 2001
Posts: 2370

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?).


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
hao li
Greenhorn

Joined: Jul 24, 2002
Posts: 21
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

Joined: Jul 05, 2001
Posts: 2370

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

Joined: Feb 05, 2002
Posts: 18
Mark,
What do you think about it?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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:


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
XJ LIN
Greenhorn

Joined: Feb 05, 2002
Posts: 18
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

Joined: Aug 26, 2001
Posts: 7610
right... sorry again, I'm doing the beta exam and our DB interface does not have any close() method...
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
hao li
Greenhorn

Joined: Jul 24, 2002
Posts: 21
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

Joined: Jul 24, 2002
Posts: 21
Hi, Michael Morris,
Thanks, I did it. I like your design!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about method close
 
Similar Threads
Closing the database.
Closing DB issue in new method
Client socket closing.
How to stop rmi server?
FBN: Closing the database in Network mode.