Restrict postgres access from java clients by using the java program on a server

advertisements

Perhaps this question is not very clear but I didn't find better words for the heading, which describes the problem I like to deal with shortly.

I want to restrict access from a java desktop application to postgres.

The background:

Suppose you have 2 apps running and the first Application has to do some complex calculations on the basis of data in the db. To nail the immutability of the data in the db down i'd like to lock the db for insert, update and delete operations. On client side i think it's impossible to handle this behaviour satisfactory. So i thought about to use a little java-app on server-side which works like a proxy. So the task is to hand over CRUD (Create Read Update Delete) operations until it gets a command to lock. After a lock it rejects all CUD operations until it gets a unlock command from the locking client or a timeout is reached.

Questions:

What do you think about this approach?

Is it possible to lock a Database while using such an approach?

Would you prefer Java SE or Java EE as server-side java app?

Thanks in advance.


Why not use transactions in your operations? The database has features to maintain data integrity itself, rather than resorting to a brute operation such as a total-database lock.

This locking mechanism you describe sounds like it would be a pain for the users. Are the users initating the lock or is the software itself? If it's the users, you can expect some problems when Bob hits lock and then goes to lunch for 2 hours, forgetting to unlock the database first...