Originally posted by parmeet bedi:
Its not beacuse of .next()
I tried to use first() method but it gives an error
Exception in thread "main" java.lang.UnsupportedOperationException
at sun.jdbc.odbc.JdbcOdbcResultSet.first(Unknown Source)
at tableNames.main(tableNames.java:103)
parmeet:
your problem lies in the type of statement you are creating. By default the cursor is of type forward only which allows you to use the ResultSet.next() method. It however will not let you use the method ResultSet.first() as it may have to move the cursor backwards. If you want to use the .next/.last methods then you have to declare a statement of type scroll insensitive(can move forwards and backwards through the resultset. Here is an example:
ResultSet results;
Statement statement;
statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
results = statement.executeQuery(query);
results.last();
transfers = results.getRow(); //returns the number of rows returned by the query
results.first();
//continue processing the results...
hope that helps,
Jamie