My objective is to be able to run Descriptive Statistics mySQL queries on my tables on Java. Some of these queries consist of several parts to get one result such as getting a median of a column which is comprised as follows:
set @ct := (select count(1) from employee);
set @row_id := 0;
select avg(VacationHours) as median
from (select * from employee order by VacationHours) AS T
where (select @row_id := @row_id + 1)
between @ct/2.0 and @ct/2.0 + 1;
Basically I want to run that query all at once which technically consists of 3 parts. So far all the questions regarding running multiple queries at once consisted of either just SELECT or UPDATE which isn't exactly describing my situation. I have tried adding ?allowMultiQueries=true
to the end of my dbURL to no avail.
The code I am using right to execute the above SQL is by using
pStmt = conn.prepareStatement(sql);
rs = pStmt.executeQuery(sql);
which is giving me the error java.sql.SQLException: ResultSet is from UPDATE. No Data.
Any help would be much appreciated :)