bguiz
bguiz

Reputation: 28587

Csv Jdbc : ResultSet.getRow() unsupported

How do I enable ResultSet.getRow() in CsvJdbc?

(this is a function that is supposed to return the current row number)

It appears to be dependent on an isScrollable member. If anyone has encountered this before, how do you work around it?

Thanks!


More Info

An application I use has the capability of importing data from any JDBC source. I need to get some data from CSV files into it, hence I'm using CsvJdbc. This application needs to access the row numbers of each line of data it imports, and unfortunately CsvResultSet#getRow() throws an exception, complaining that "Csv Jdbc : ResultSet.getRow() unsupported".

The following is the impl. of the getRow() method in CsvJdbc (1.0.5)

/**
 * Retrieves the current row number.  The first row is number 1, the
 * second number 2, and so on.
 *
 * @return the current row number; <code>0</code> if there is no current row
 * @exception SQLException if a database access error occurs
 */
public int getRow() throws SQLException {
    if (this.isScrollable == ResultSet.TYPE_SCROLL_SENSITIVE) {
        return currentRow;
    } else {
      throw new UnsupportedOperationException(
            "ResultSet.getRow() unsupported");
    }
}

Looking through the rest of the source it seems that the only place that the isScrollable member property is set is in the constructor and as a default value.

Upvotes: 1

Views: 793

Answers (1)

l_39217_l
l_39217_l

Reputation: 2110

Have you tried creating a scrollable statement...

Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

Upvotes: 2

Related Questions