Hello again people.

I have a problem.

Think of a textarea. The text area is filled with information depending on an entrance in a textbox.

Like userID is entered and the information is filled in the textarea.

I want the user to edit the textarea. But when he is editing, the information are called important and umimportant data. Important data is not to be edited. Unimportant data can be edited.
So i have 2 textareas first one is editable and the second one is noneditable.

To continue to my problem, i want to say this. The unimportant and important data is mixed in the database. The first record is UNIMP the second is IMP the third IMP the fourth UNIMP exc.....

What i want to do is allow user to edit the unimportant data which is in the editable text area. Also after the updating, i want the unimportant to be the first records of database. So when i handle with this problem;

User enters a userID and clicks a button.
Information(a and b) is filled in a text area.
a is unimportant and b is important.
Information a is edited.
User clicks "update" button

The rows regarding to previous a and be is deleted.(query1)

textarea of UNIMP data is inserted and textarea of IMP data is inserted(query2)

What i am afraid is what if something happens between query1 and query2.
The important data might be deleted and never come back.

Note: Data is recorded in the database with white space characters.

For example;

Hello. I don't like my name.

But i like the way i look.

This is recorded as

Row1-Hello. I don't like my name.
Row3-But i like the way i look.

in the database


From what I understood, first you delete and then you insert, when you want to do an Update.

Well you can try and run an Update query. When you "SELECT" data from the database you use a userID as you say in your example. Probably you use it at your "WHERE" clause at the query to get the data (UNIMP and IMP).
You can have ONE update query setting the values of the UNIMP and IMP data taken from the TextFields.

Or if for some reason that cannot be done, you can use "commit", "rollback".
First set the autoCommit of the connection to false.
Run your queries.
If both where executed: commit and set back the connection's autoCommit to true
Else if there was an exception do a rollback inside the "catch (Exception e) " and again set back the connection's autoCommit to true

All the above methods are available from the Connection class. Check its API for more info

Well, your second suggestion works very good...

Thanks for the information.