'PreparedStatement getMaxRows always returns 0

So i have a problem where i want to see how many rows there are in my database, after i've made an update. Im trying to use "GetMaxRows" but it always returns 0. i suspect that it is because i dont have a ResaultSet, but i can't get that when using PreparedStatement.executeUpdate()? Any suggestions or mistakes i've made?

protected void createOrder(Carport carport, Shed shed, User user){

    Logger.getLogger("web").log(Level.INFO, "");

    String sql = "insert into carport.order (length, width, material, userId, shedIncluded) values(?,?,?,?,?)";

    int shedIncluded = 1;
    if (shed == null) shedIncluded = 0;

    int maxRows = 0;

    try (Connection connection = connectionPool.getConnection()) {
        try (PreparedStatement ps = connection.prepareStatement(sql)) {
            ps.setInt(1, carport.getLength());
            ps.setInt(2, carport.getWidth());
            ps.setString(3,carport.getMaterial());
            ps.setInt(4,user.getUserId());
            ps.setInt(5,shedIncluded);
            int rowsAffected = ps.executeUpdate();
            int test = ps.getMaxRows();
            System.out.println(test);

            if(rowsAffected == 1){
                System.out.println("Carport data is saved");
            }
            else{
                throw new DatabaseException("Could not save Carport data");
            }
        }
    } catch (SQLException | DatabaseException throwables) {
        throwables.printStackTrace();
    }
    if(shedIncluded == 1) createShedOrder(shed, maxRows);
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source