Thread: Resultset funnies...
Hi all What am I doing wrong in the code below? The 2nd while(rs.next()) loop isn't entered at all, and I definitely have 1 row returned. Any help much appreciated, thanks :) Ciao Zak int i = 0; while (rs.next()) { i++; } rs.first(); returnData = new Object[i][numCols]; System.out.println(i+" number rows returned"); for (i=1; i <= numCols ; i++) { colTypeName[i-1]=rsmd.getColumnTypeName(i); colType[i-1]=rsmd.getColumnType(i); colName[i-1]=rsmd.getColumnName(i); System.out.println(i + ": " + colName[i-1]); } int j=0; rs.first(); System.out.println("Here..."); while(rs.next()) { for (i=1; i <= numCols ; i++) { // colName[i]=rsmd.getColumnName(i); //colType[i]=rsmd.getColumnType(colName[i]); System.out.println(i+": "+colName[i-1].toString()); returnData[j][i-1]=rs.getString(colName[i-1].toString()); System.out.println("***"+returnData[j][i-1]); } j++; } System.out.println("here now..."); rs.close(); -- -- ======================================================================== http://www.carfolio.com/ Searchable database of 10 000+ car specs Auctioning motoring-related items at eBay? http://www.carfolio.com/ebay/ ========================================================================
On Mon, 8 Sep 2003 15:25:47 +0200 Zak McGregor <zak@mighty.co.za> wrote: > Hi all > > What am I doing wrong in the code below? The 2nd while(rs.next()) loop isn't > entered at all, and I definitely have 1 row returned. Any help much > appreciated, thanks :) [snip] > rs.first(); > System.out.println("Here..."); > while(rs.next()) { > for (i=1; i <= numCols ; i++) { ... Changing the above instance of first() to beforeFirst() seems to have fixed my problem. Ciao -- ======================================================================== http://www.carfolio.com/ Searchable database of 10 000+ car specs Auctioning motoring-related items at eBay? http://www.carfolio.com/ebay/ ========================================================================
On Mon, 8 Sep 2003 09:55:13 -0400 (EDT) Richard Welty <rwelty@averillpark.net> wrote: [snip] Hey Richard :) Seems our interests overlap more than I realised :) (also Italian cars & Alfa digester) Ciao Zak -- ======================================================================== http://www.carfolio.com/ Searchable database of 10 000+ car specs Auctioning motoring-related items at eBay? http://www.carfolio.com/ebay/ ========================================================================
On Mon, 8 Sep 2003 16:20:07 +0200 Zak McGregor <zak@mighty.co.za> wrote: > On Mon, 8 Sep 2003 09:55:13 -0400 (EDT) > Richard Welty <rwelty@averillpark.net> wrote: > Hey Richard :) > Seems our interests overlap more than I realised :) > (also Italian cars & Alfa digester) yes, these things happen. i've been doing substantial amounts of PostgreSQL work for 2 years now, and it's been Java/JDBC/PostgreSQL almost exclusively for the past year with occasional visits to PHP land. i also thought i hadn't sent that previous message to the whole jdbc list. if i did, i apologize, it was only supposed to go to Zak. richard -- Richard Welty rwelty@averillpark.net Averill Park Networking 518-573-7592 Java, PHP, PostgreSQL, Unix, Linux, IP Network Engineering, Security