conn =mysqljdbcutils.getconnection (); Statement PS=conn.createstatement ();p S.addbatch ("Truncate Qb_showcount_asite_copy");p S.executebatch (); String Srcsql= "SELECT Convert" (Unhex (Hex (CONVERT (Community using latin1)) using UTF8) as Community, PID from Qb_menbercmmsets_list whe Re site=7 "; stmt=conn.preparestatement (Srcsql); RS=Stmt.executequery () above is the empty command executed before the following SQL statement is executed//Bulk execution of SQL statementsSolution One statement PS=conn.createstatement ();p S.addbatch ("Update user set money=money-100 where name= ' Zhang San '");p S.addbatch ("Update user set money=money+100 where name= ' John Doe '");p S.addbatch ("Update temp set count=count+1 where Name= ' Zhang San '");p S.executebatch (); However, the use of statement, can only be used to use the concatenation of strings, to pass the value; scenario two if multiple statements are repeated, but the parameters are unchanged, you can preparedstatement PS=conn.preparestatement ("INSERT into temp values (?)");p S.setint (1, 100);p S.addbatch ();p S.setint (1, 200);p S.addbatch ();p s.executebatch (); Scenario three write a stored procedure Laugh reference http://blog.csdn.net/cnmcxiari/article/details/6632975
JDBC connects MySQL, executes SQL statements in bulk, or executes an SQL statement before executing an SQL statement