Also, in case you have many records you're pulling up yo may not want to
cycle through all of them.
Use: "Select count(*) as totalRecordsField from foo" and then pull the
value of the "totalRecordsField". This is a easier query on the DB as you
need not deal with the cursor as much.
Matt
Matthew L. Wright
Java Internet Programmer
Jupiter One
Web World Studios West Coast
www.jupiterone.com
(818) 763-2927
----- Original Message -----
From: "Moore, Jim" <[EMAIL PROTECTED]>
To: "JRun-Talk" <[EMAIL PROTECTED]>
Sent: Friday, March 30, 2001 12:36 PM
Subject: RE: Re[2]: getRowCount()
> String sql = "SELECT * FROM foo";
> Statement stmt = conn.createStatement();
> ResultSet rs = stmt.executeQuery(sql);
> int rowcount = rs.getRow();
> rs.beforeFirst();
> while (rs.next()) {
> file://process resultset
> }
>
> or
>
> String sql = "SELECT * FROM foo";
> Statement stmt = conn.createStatement();
> ResultSet rs = stmt.executeQuery(sql);
> int rowcount = 0;
> while (rs.next()) {
> file://process resultset
> rowcount++;
> }
>
> --jim
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 30, 2001 3:13 PM
> To: JRun-Talk
> Subject: Re[2]: getRowCount()
>
>
>
>
>
> Additional Header Information:
> Received: from www.houseoffusion.com ([207.31.122.140]) by inside.pgi.com
> (Lotus
> SMTP MTA v4.6.6 (890.1 7-16-1999)) with SMTP id 85256A1F.006958EB; Fri,
30
> Mar
> 2001 14:10:40 -0500
> Received: from houseoffusion.com ([207.31.122.140])
> by www.houseoffusion.com (Post.Office MTA v3.5.3
> release 223
> ID# 0-54969U100L100S0V35) with ESMTP id com
> for <[EMAIL PROTECTED]>;
> Fri, 30 Mar 2001 13:56:17 -0500
> Content-type: text/plain
> Content-type: text/plain
> Date: Fri, 30 Mar 2001 13:42:43 -0500
> From: [EMAIL PROTECTED]
> Message-id:
> <3312CFEA8474D411BAB600508B9587B21CE785@S0001EXC0007>
> Subject: RE: getRowCount()
> Reply-To: [EMAIL PROTECTED]
> To: JRun-Talk <[EMAIL PROTECTED]>
>
>
> ---------------------------------
>
>
>
>
> if I don't use allaire tag, how can I get the recordcount after I ran a
> query?
>
>
>
>
> thank you
>
> YC
>
>
> <%@ page import='allaire.taglib.*' %>
> <j:sql datasrc='...' id='result'>
> ....
> <j:sql>
>
> <%
> QueryTable t = (QueryTable)pageContext.getAttribute("result");
> out.print(t.getRowCount());
> %>
>
> In JRun 3.1 (currently in beta), you should be able to treat the query
> object
> like javax.sql.RowSet.
>
> -C
>
> --
> Clement Wong
> JRun Engineer, Macromedia
> http://www.macromedia.com
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists