java - I have to insert three rows in to sql server at a time -


i have insert 3 rows in sql server java @ time , not want other rows between them other threads . can that?

use java.sql.statement.addbatch(), java.sql.statement.executebatch.
more details see link

string [] queries = {     "insert employee (name, city, phone) values ('a', 'x', '123')",     "insert employee (name, city, phone) values ('b', 'y', '234')",     "insert employee (name, city, phone) values ('c', 'z', '345')", }; connection connection = new getconnection(); statement statement = connection.createstatement();  (string query : queries) {     statement.addbatch(query); } statement.executebatch(); statement.close(); connection.close(); 

but if have multiple threads inserting in same table might need synchronized inserting method
synchronized details


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -