Simplejdbctemplate Update operations
String Insertsql= "INSERT into users values (2, 'Lisi', 2)";
// insert a row of records into the table, Row indicates the number of rows affected
int row=stj.update (insertsql);
System.out.println (row);//1
support for variable parameter update tables
String insertsql="insert into users values (?,?,?)";
Integerid=integer. valueOf (5);
String name="Xiaoqi";
Integerage=integer. valueOf (5);
int row= stj.update (Insertsql, id,name,age);
System. out. println (row); //1
String insertsql="Insertinto Users Values (: id,:name,:age)";
map<string,object> Map=newhashmap<string,object> ();
map. Put ("id", Integer. ) ValueOf(8));
map. Put ("name","Huangba");
map. Put ("age", Integer. ) ValueOf(8));
int row=stj.update (insertsql,map);
System. out. println (row);
Support for multi-line update operations
String insertsql2="Insertinto users Values (?,?,?)";
Integer Id=integer. valueOf (12);
String name="yaoling";
Integer Age=integer. valueOf (12);
Object[] Object1={id,name,age};
Integer Id2=integer. valueOf (11);
String name2="Jiujiu";
Integer Age2=integer. valueOf (11);
Object[] Object2={id2,name2,age2};
list<object[]> list=Newarraylist<object[]> ();
List.add (Object1);
List.add (OBJECT2);
Returns the number of rows that correspond to the effect
int [] row2=stj.batchupdate (INSERTSQL2, list);
Update operations for Simplejdbctemplate in spring