469,609 Members | 2,214 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Lock DB record or Lock JSP page record/button

2,364 Expert 2GB
Hey Ladies and Gents!

I would like to permit only one user edit to a row in a database. I am a firm believer at having the db do most of the work but the app I am maintaining could use some robustness; as a couple of users were picked up to have updated the same record, at the same time.

Do you think locking the database per user instance (which I have no idea about, as of yet) is a better approach than locking/disabling the update button based on the JSP page opened (EditEmployeeItems.jsp)...

Got some links on locking through DB:




If you could provide better links that'll help me achieve this through the DB that'd be great


My other option is:

(1) read the user's IP, who frst loaded EditEmployeeItems.jsp
(2) submit the date/time the page is retrieved
(3) compare with today's date/time
(4) lock/disable the update button on that page,
(5) throw a message to user that page is being updated

Expand|Select|Wrap|Line Numbers
  1. public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  3.         // Get User IP
  4.         String UserIP = req.getRemoteAddr();    
  6.     } 

below may be incorrect, but that's the idea I am attempting...

Expand|Select|Wrap|Line Numbers
  2. ....
  3.                int UserName=rs.getInt(1);
  6.             session.setAttribute("UserName",UserName);
  7.             session.setAttribute("LogTime",LogTime); //date/time auto populate
  9.             String queryString = "INSERT INTO RETRIEVEDJSP set UserName="+UserName+",LogTime='"+LogTime+"'"; //submit an Autodate (java.sql)
  11. ....
I could also simpy disable the link to the page, and avoid having to read user attempts to edit, unless it is the first instance.

What are your thoughts? Thanks for your much needed response.

In a bit!

Nov 22 '09 #1
1 2960
2,364 Expert 2GB
any ideas guys!

I have researched the articles, gives me something to work with. But I could not find anything about the benefit to using one option over the other.

Any input you have is helpful.

Thanks for your help...
Dec 3 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Andy | last post: by
11 posts views Thread by John A Grandy | last post: by
2 posts views Thread by brino | last post: by
5 posts views Thread by prakashwadhwani | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.