On Sun, 7 Jun 2009 12:47:58 -0500, P Kishor <punk.k...@gmail.com> wrote:
>2009/6/7 Nuno Magalhães <nunomagalh...@eu.ipp.pt>: >> Greetings, >> >> I'm using SQLite for an academic project, through Java's JDBC >> (sqlitejdbc-0.5.4.jar). After executing a simple select, i can iterate >> the ResultSet all the way (showing to output), no problem. The >> problem, which may be silly, is that i need to get a row count so i >> can initialize a variable. >> >> I tried using rs.getFetchSize() but it returns 0. This is the only >> method i could relate to "getting number of rows" from the method >> list. >> >> I tried rs.last(); but get "SQLException: ResultSet is >> TYPE_FORWARD_ONLY" and wouldn't be able to get back anyway. >> >> I tried iterating the set and using rs.isLast() but i get >> "SQLException: function not yet implemented for SQLite". >> >> I know this si more related to JDBC than SQLite, but maybe someone can >> give me a hint? > >Either run a SELECT Count(*) prior to running your full select query, >or run the SELECT query, iterate over it counting the records, find >the total number in the set, and then iterate over it and display as >you are doing now. Either way, you would have to do a two-pass. I >would prefer the two SELECTs, once for the Count() and second time for >the query, for small results sets ... keep in mind, SELECT Count() in >SQLite is not optimized. It has recently been optimized, but only for the form: SELECT count(*) FROM <tbl> without WHERE or LIMIT clauses. http://www.sqlite.org/cvstrac/chngview?cn=6316 >For big result sets, I might want to just do >one mongo select and then count the results in memory. -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users