Modify a record using jdbc??

Posted on 2004-11-14
Last Modified: 2010-04-17
How to modify a record using jdbc??

The method i am using now is:

Display record
Ask user to insert new values.
then update table.

is there a direct way of displaying the record and the user overwrite the data??
Another way??
Question by:SniperVishal
    LVL 21

    Expert Comment

    There is a way, it is called updatable result sets.  Here is Java's tutorial:

    The only problem with this method is that it usually locks the database for the duration of the tranaction (The transaction lasts until the resultset is closed).  You need to look at your processes and determine the probability of two users accessing the same record at the same time.  If the probabilty is low, then don't worry about it, otherwise check out this thread:

    Author Comment

    i want the a record field to be displayed which the user can modify there itself on the console....

    LVL 21

    Accepted Solution

    as long as concurency is not an issue, just do the following:

      1) Select results
      2) Store ResultSet in an Object
      3) Close statement, and connection (Don't close resultset)
      4) Return object containing ResultSet
      5) Display ResultsSet do user and allow changes
      6) Propogate changes back to resultSet
      7) Excecute Update on resultSet
      8) Close ResultSet

    The record being modified will be locked all through 1-8, so no other user will be able to modify that record (possibly not even select it).  When the statement is closed, the DB locks will be released.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    matchUp  challenge 6 36
    zeroMAx challenge 20 66
    Batch file output 20 71
    bunnyEars challenge 6 45
    A short article about a problem I had getting the GPS LocationListener working.
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now