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:
http://www.vsj.co.uk/databases/display.asp?id=522
http://articles.techrepublic.com.com...1-5181472.html
http://www.sqlmag.com/Article/Articl...ver_25916.html
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
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
- // Get User IP
- String UserIP = req.getRemoteAddr();
- }
below may be incorrect, but that's the idea I am attempting...
Expand|Select|Wrap|Line Numbers
- ....
- int UserName=rs.getInt(1);
- session.setAttribute("UserName",UserName);
- session.setAttribute("LogTime",LogTime); //date/time auto populate
- String queryString = "INSERT INTO RETRIEVEDJSP set UserName="+UserName+",LogTime='"+LogTime+"'"; //submit an Autodate (java.sql)
- ....
What are your thoughts? Thanks for your much needed response.
In a bit!
Dököll