Java 呃,很有帮助。 //insert data into table X ; //update records of table X ; insert into Activity select * from (select ?, ?, ?, ?) as te

Java 呃,很有帮助。 //insert data into table X ; //update records of table X ; insert into Activity select * from (select ?, ?, ?, ?) as te,java,mysql,prepared-statement,rows-affected,Java,Mysql,Prepared Statement,Rows Affected,呃,很有帮助。 //insert data into table X ; //update records of table X ; insert into Activity select * from (select ?, ?, ?, ?) as temp where not exists(select * from Activity where ActivityName=?); update Activity set EmployeeeName=?, DepartmentName=?, r

呃,很有帮助。
//insert data into table X ;
//update records of table X ;
insert into Activity
select * from (select ?, ?, ?, ?) as temp
where not exists(select * from Activity where ActivityName=?);
update Activity
set EmployeeeName=?, DepartmentName=?, roleId=? 
where ActivityName=?;
    try {
      // statement to insert like
      // insert into Activity (ActivityName, EmployeeeName, DepartmentName, roleId)
      //     values (?, ?, ?, ?)
    } catch ... {
      // If the exception is caused by primary key violation,
      // then such ActivityName already existed and we can ignore this exception
    }