Re: MySQL ResultSet - count rows?



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.

--
Lew
.



Relevant Pages

  • Re: MySQL ResultSet - count rows?
    ... Lew wrote: ... Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ... int n = rs.getRow; ... I'm guessing that it's the overhead of going first / last / first on large datasets. ...
    (comp.lang.java.databases)
  • Re: Threads and synchronization
    ... int i = 100; ... Never never publish a this pointer from a constructor. ... context switching still happen, even if B and C won’t do anything due ... I think the rest of Arne answers are easy to understand but I'm still kinda confused by the first one. ...
    (comp.lang.java.programmer)
  • Re: Generating a unique string without normal character sets
    ... Arne Vajhøj wrote: ... create Strings that can be accessed at larger indexes than integers ... allow, for example, using a non-array implementation? ... http://java.sun.com/javase/6/docs/api/java/lang/String.html#indexOf (int) ...
    (comp.lang.java.programmer)
  • Re: how to execute a class as an external Java application
    ... Arne, ... String path = cls.getClassLoader.getResource ... int ix = path.lastIndexOf; ... catch (IOException ex) { ...
    (comp.lang.java.programmer)
  • Re: dynamic linker problem
    ... Kimura Fuyuki writes: ... > int main ... Arne ... To unsubscribe, ...
    (freebsd-current)