Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution time of consecutive executeUpdate() SQL statements

How safe is it to use multiple consecutive executeUpdate() methods on SQL database?

Considering 2 statements:

st.executeUpdate("INSERT table SELECT col1,col2 FROM table WHERE ID=" +var_id);
st.executeUpdate("DELETE FROM table WHERE ID=" +var_id);

How does they behave? Does the 2nd statement wait for the completion of 1st or should we check for the returned value (number of rows affected) and act accordingly with 2nd statement?

like image 266
yosh Avatar asked Jul 10 '12 15:07

yosh


1 Answers

A call to executeUpdate is not asynchronous, so it will not return until after the statement has been executed on the server. In other words: these two statements will work and they will not interfere as they are executed one after the other.

like image 95
Mark Rotteveel Avatar answered Jan 13 '23 00:01

Mark Rotteveel