?
Solved

Modify a record using jdbc??

Posted on 2004-11-14
5
Medium Priority
?
228 Views
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??
0
Comment
Question by:SniperVishal
  • 2
3 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 12582676
There is a way, it is called updatable result sets.  Here is Java's tutorial:
http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/makingupdates.html

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:
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21107702.html
0
 

Author Comment

by:SniperVishal
ID: 12590904
i want the a record field to be displayed which the user can modify there itself on the console....

0
 
LVL 21

Accepted Solution

by:
MogalManic earned 400 total points
ID: 12592251
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in 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 …

807 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