Hi,

> I use H2 in a Java-Swing-application and would like to make it "multi-
> user-able" and i would like to know with techniques of H2 exists to
> make this "easier" realizable.

> - Administration of customers with an interface to edit their profiles
> (JFrames).
> In this JFrame i use f.e. JTables, JTextFields, etc. and fill them
> with the data of the database.
>
> Now occures the problem when 2 users work at the same time at the same
> user profile...

One 'solution' is: you could simply allow multiple concurrent users to
work on the same data. Some applications do that, but there is a risk
of lost data. If the risk and amount of lost data is small, then you
could simply ignore or document this problem.

If loosing data is not acceptable, one solution is to use a
'timestamp' or 'version' column on update, so you can check if
somebody else changed the row while editing it. Example:

select firstName, lastName, version from users where id=1;
... then let the user edit the data ...
update users set firstName=?, lastName=?, version=version+1 where id=?
and version=?

Then check the update count. If it's zero, that means somebody else
updated or deleted the row. In that case you may want to display an
error page 'Somebody else changed the data, overwrite? / cancel?' or
something like that.

> What is a good way to manage this and are their possibilities to
> handle this with H2?

I believe this question is not really specific to H2. You can and
should solve this in a database independent way, specially because it
is related to 'long running transactions'. This should be handled in
the application anyway and not in the database, otherwise your
application will be very hard to port to another database.

Regards,
Thomas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to