I am building small e-banking project in java for better understanding of RMI.
Actually, I have thought about possibility of having any kind of errors while executing client request for depositing money to his bank account.
In other words, let's consider there is a client who wants to deposit money to his bank account, so the client program will send a request to the server in order to execute distant method deposit()
remotely. Now let's suppose that the request couldn't be sent at a moment because some errors, so the client will send new request because the server didn't receive the first one. The second request has been executed correctly. Now suppose that after a while the server receives the first request and executes it, here comes the problem: the request has been executed twice but the client wanted to deposit money only one time.
What I have tried so far is to add a column in the Client table ( containing idClient and password and balance ) named idRequest to check if there is a previous request sent before executing it. But it seems bad solution.
How can i solve this problem in a better way ( without adding new column in the table of client data in the database in order to identify the last request sent )?
Your question doesn't make sense. The situation you describe is impossible. An RMI client can't call a second remote method until the first remote method returns, unless it is multithreaded, in which case the simpe solution is to remove the multi-threading. And when the method returns it has completely executed at the server.
TCP also prevents data from arriving out of sequence, although RMI can use multiple connections which makes that a bit irrelevant.
You also need to be aware that RMI has 'at-most-once' delivery semantics.
You seem to be inventing problems where none exists.
You do however need to look up 'transactional idempotence', for other reasons.