[tinysql] Implementation of absolute method of JDBCResultSet
dan carter
dcarter@waitaki.otago.ac.nz
Tue, 18 Mar 2003 22:56:09 +1200
This is a multi-part message in MIME format.
--------------030807080207040208090309
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
I needed it for a JDBCIterator implementation for my project, thought
i'd share it.
You might want to investigate the line:
if( size == -1 ) result.getResultRowAt(0);
I don't know why by getResultSize() returns -1 if you haven't already
retrieved a row.
Oh, and i also implemented getRow()
--------------030807080207040208090309
Content-Type: text/plain;
name="absolute.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="absolute.diff"
Index: src/ORG/as220/tinySQL/tinySQLResultSet.java
===================================================================
RCS file: /home/cvsroot/tinySQL/src/ORG/as220/tinySQL/tinySQLResultSet.java,v
retrieving revision 1.9
diff -w -r1.9 tinySQLResultSet.java
1292c1292,1293
< return 0;
---
> //return 0;
> return current_row_index+1;
1325a1327,1338
>
> try
> {
> int size = result.getResultSize();
> if( size == -1 ) result.getResultRowAt(0);
> size = result.getResultSize();
> if( row < 0 )
> {
> row = size+row;
> if(row < 0)
> {
> current_row_index=-1;
1327a1341,1364
> }
>
> if( row == 0 )
> {
> current_row_index=-1;
> return false;
> }
> else if( row > size )
> {
> current_row_index=size;
> return false;
> }
> else
> {
> current_row_index=row-1; // -1 to convert between 0 origin and 1 origin indexes
> current_row = result.getResultRowAt(current_row_index);
> return true;
> }
> }
> catch (Exception e)
> {
> throw new tinySQLException(e.getMessage(), e);
> }
> }
--------------030807080207040208090309--