Re: numrows

From: Jeremy Buchmann <jeremy(at)wellsgaming(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Cc: ricardo_jal(at)hotmail(dot)com
Subject: Re: numrows
Date: 2002-12-20 00:17:40
Message-ID: 738BF76C-13B0-11D7-84CC-000502E740BA@wellsgaming.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Or you could do:

rs.last();
int numRows = rs.getRow();
rs.first();

That way you wouldn't have to scroll through the result set or run
another query. Of course, you should error check rs.last() the
same way you'd check rs.next().

--Jeremy

On Thursday, December 19, 2002, at 03:59 PM, Dave Cramer wrote:

> Ricardo,
>
> There's no way after the fact other than counting them, ie scrolling
> through them and keeping track.
>
> However for simple selects you can do
>
> select count(*), * from user where id=3
>
> and count will contain the count.
>
> Dave
> On Thu, 2002-12-19 at 17:04, Ricardo Javier Aranibar León wrote:
>> Hi list,
>>
>> How I can figure out the number of rows from the query?
>> For example:
>> String q1= "Select * from user where id=3";
>> PreparedStatement ps = conex.prepareStatement(q1);
>> ResultSet rs = ps.executeQuery();
>>
>> //Now how i can to know the number of rows from select?
>>
>> REgards,
>> Ricardo
>>
>>
>>
>>
>> _________________________________________________________________
>> MSN Fotos: la forma más fácil de compartir e imprimir fotos.
>> http://photos.msn.es/support/worldwide.aspx
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 2: you can get off all lists at once with the unregister command
>> (send "unregister YourEmailAddressHere" to
>> majordomo(at)postgresql(dot)org)
> --
> Dave Cramer <Dave(at)micro-automation(dot)net>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Noel 2002-12-20 00:35:00 Re: error when using move, any suggestions?
Previous Message Dave Cramer 2002-12-19 23:59:26 Re: numrows