Modify a record using jdbc??

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??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:
SniperVishalAuthor Commented:
i want the a record field to be displayed which the user can modify there itself on the console....

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.