prestodb/presto · error · SQLFeatureNotSupportedException
previous
Error message
previous
What it means
previous() in PrestoResultSet always throws SQLFeatureNotSupportedException: result sets are TYPE_FORWARD_ONLY, so backward cursor movement through the rows is impossible and the method is unimplemented.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:692
@Override
public boolean absolute(int row)
throws SQLException
{
throw new SQLFeatureNotSupportedException("absolute");
}
@Override
public boolean relative(int rows)
throws SQLException
{
throw new SQLFeatureNotSupportedException("relative");
}
@Override
public boolean previous()
throws SQLException
{
throw new SQLFeatureNotSupportedException("previous");
}
@Override
public void setFetchDirection(int direction)
throws SQLException
{
checkOpen();
if (direction != FETCH_FORWARD) {
throw new SQLException("Fetch direction must be FETCH_FORWARD");
}
}
@Override
public int getFetchDirection()
throws SQLException
{
checkOpen();
return FETCH_FORWARD;View on GitHub (pinned to 55bb57d202)
Solutions
- Restructure logic to a single forward pass, buffering any rows you may need again
- Re-execute the query to restart iteration
- Collect rows into a ListIterator-backed in-memory structure for bidirectional traversal
Example fix
// before
rs.next(); rs.next(); rs.previous(); // step back
// after
List<Row> rows = new ArrayList<>();
while (rs.next()) { rows.add(readRow(rs)); }
ListIterator<Row> it = rows.listIterator(); Defensive patterns
Strategy: try-catch
Validate before calling
DatabaseMetaData md = conn.getMetaData();
if (!md.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)) { /* no backward iteration */ } Try / catch
try { rs.previous(); } catch (SQLFeatureNotSupportedException e) { /* buffer rows or re-execute */ } Prevention
- Design iteration as single-pass forward only
- Buffer rows in a List when bidirectional access is required
- Restart iteration by re-executing the statement
When it happens
Trigger: Calling ResultSet.previous() on a PrestoResultSet after advancing with next().
Common situations: Iterators that occasionally step backward, or code written against scrollable result sets on other databases reused with Presto.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/506328ca889a6c8e.
Report an issue: GitHub.