I am ranking players, and I need to get the result into Java.
My code is
public static int getRank(UUID uuid) throws SQLException {
checkConnection();
PreparedStatement s = con.prepareStatement(
"SET @rownum := 0; SELECT rank FROM ( SELECT @rownum := @rownum + 1 AS rank, wins, uuid FROM `SKYWARS` ORDER BY wins DESC ) as result WHERE uuid=?");
s.setString(1, uuid.toString());
ResultSet r = s.executeQuery();
r.next();
return r.getInt(1);
}
But s.execute() returns false which means there is no resultset. How do I get the resultset? In MySQL workbench it returns the values rank and wins in a grid.
SOLUTION:
I added ?allowMultiQueries=true
to the connection statement. This made my code work as is.