I would count the number of rows affected by the query provided as a prepared statement in java passed to a MySql engine.
Given the following sample queries passed to a prepared statement, I need to be able to count the total number of rows affected by all the queries.
//insert data into table X ;
//update records of table X ;
The queries are separated by ";" which is part of MySql syntax to support several CRUD operations over a particular PreparedStatement object. It seems when the "executeUpdate()" method is invoked, that is only the number of rows affected by the first query, i.e., insert to the table, gets returned. Do I miss something I was supposed to provide to get the number of total affected rows in such that query?
Here is the sample real code I am working on:
insert into Activity
select * from (select ?, ?, ?, ?) as temp
where not exists(select * from Activity where ActivityName=?);
update Activity
set EmployeeeName=?, DepartmentName=?, roleId=?
where ActivityName=?;
I expect the minimum of 1 as the output while get the 0 instead.