Hi, you want to scroll your resultset with the help of java. So, first determine whether your database Supports Scrollable Result Set or not. A scrollable result set allows the cursor to be moved to any row in the result set. This capability is useful for GUI tools that browse result sets.
Code:
try
{
DatabaseMetaData dm = connection.getMetaData();
if (dm.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE))
{
}
if (dm.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE))
{
}
if (!dm.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE) && !dm.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE))
{
}
}
catch (SQLException e)
{
}
If it is supporting it then just make use of following code to make it Scrollable.
Code:
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rst = stmt.executeQuery("SELECT id, name FROM student");
Bookmarks