• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client - database disconnection

 
Manish Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When I disconnect the database in local mode from the client I have used to invoke the close method of the Data class. But the close method doesn't throw any exception.
I feel that the close method should throw some exception.
Please correct if i'm wrong..

Also, I'm NOT getting a good way of disconnecting the server from the client for the REMOTE Mode connection.
For remote mode disconnection, I put a null value to my connection object and set the connection flag to false.
Is there any better way to that?

Your comment will be appreciated.
Thanks & regards.

Manish
------------
-SCJP2
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manish,

Hi,
When I disconnect the database in local mode from the client I have used to invoke the close method of the Data class. But the close method doesn't throw any exception.
I feel that the close method should throw some exception.

When you say disconnect, what exactly do you mean? Do you still hava a reference to a Data object? Have you just called close() on the Data object?
Does it make sense to allow close() to be called on Data multiple times without it throwing an Exception? If that's your question, I can see merit in doing it either way. The designer of the Data class chose the no hassle approach since it really does not make any difference if you call close once or 100 times. And don't forget that the finalize method of Data calls close(), so what happens if it throws an Exception from the gc after you close() Data and there are no further references to it? If you are wanting to have close() throw an Exception after Data has already been closed, I think you should probably reconsider and leave well enough alone.

Also, I'm NOT getting a good way of disconnecting the server from the client for the REMOTE Mode connection.
For remote mode disconnection, I put a null value to my connection object and set the connection flag to false.
Is there any better way to that?

Where are you keeping a reference to remote objects on the server? A better question is why do you need to keep a reference to remote objects in the server? Just let RMI and the DGC take care of orphaned connections. If you implement Unreferenced on your remote objects then you can do any clean up there, when the DGC determines that there are no more reachable remote references to the object.
Hope this helps,
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic