Re: MySQL ResultSet - count rows?



Lew wrote:
Arne Vajhøj wrote:
Dyreatnews@xxxxxxx wrote:
On the other hand; if you're using a scrollable result set, you can loop
over it to find the size,

You don't even need to loop.

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT * FROM T1");
rs.last();
int n = rs.getRow();
rs.first();

But I would never use that construct.

Arne: What are the dangers of that construct?

I'm guessing that it's the overhead of going first / last / first on large datasets.

Most (maybe all) drivers will implement that scrollable
feature by reading all data into memory.

medium data size => bad performance

large and huge data => OutOfMemoryError

Arne
.



Relevant Pages

  • Re: Graphics - how to show partial progress.
    ... Lew: I see the point about not starting threads from inside ... final int biXpos = 30; ... mOffScreenImage = new BufferedImage(biWidth, ...
    (comp.lang.java.help)
  • Re: Math.random()
    ... Lew wrote: ... int _indx; ... and this works fine except I would like the option of running the class again to shuffle the images again, but, just like before, once the files ... the images ARE being shuffled every time I run the class, but they only get renamed the first time I run the class ...
    (comp.lang.java.help)
  • Re: Translate C expression to Java expression
    ... it implies malice to me. ... Calling an argument a straw man implies _TO ME_ that the argument ... Lew, are you trolling or do you just not understand? ... "It's still an int.", where 'it' can only refer to the ...
    (comp.lang.java.help)
  • Re: help with this game
    ... 'int' object is not callable ... You only want to give players 10 chances to guess the number - but, ... If the player keeps guessing ... > ok now that i know the random function, ...
    (comp.lang.python)
  • Re: dinkumware 402 linking with g++ 3.x/ _Winit undefined ref
    ... I'm guessing it chokes on the fact that the mainyou have defined is not ... actually a function definition. ... int is the *only* valid return type for main. ...
    (comp.lang.cpp)