Lock DB record or Lock JSP page record/button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    Lock DB record or Lock JSP page record/button

    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 (EditEmployeeIt ems.jsp)...

    Got some links on locking through DB:





    ITProToday.com is a leading online source of news, analysis and how-to's about the information technology industry.


    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 EditEmployeeIte ms.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

    [CODE=JAVA]
    public void doGet(HttpServl etRequest req, HttpServletResp onse resp) throws IOException {

    // Get User IP
    String UserIP = req.getRemoteAd dr();

    }

    [/CODE]

    ...

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

    [CODE=JAVA]

    ....
    int UserName=rs.get Int(1);


    session.setAttr ibute("UserName ",UserName) ;
    session.setAttr ibute("LogTime" ,LogTime); //date/time auto populate

    String queryString = "INSERT INTO RETRIEVEDJSP set UserName="+User Name+",LogTime= '"+LogTime+" '"; //submit an Autodate (java.sql)

    ....
    [/CODE]

    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!

    Dököll
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    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...

    Comment

    Working...