H2DB supported ResultSetTypes..

.. using DatabaseMetaData!

Here is my code..
import java.sql.*;
 
import static java.lang.System.out;
import static java.sql.ResultSet.*;
 
public class ResultSetMetaDataHelloWorld {
 
    private final static String url = "jdbc:h2:~/sampleh2db;TRACE_LEVEL_FILE=0;AUTO_SERVER=TRUE";
    private final static String user = "test";
    private final static String password = "test";
 
    public static void main(final String[] args) throws SQLException {
        final Connection conn = DriverManager.getConnection(url, user, password);
        final DatabaseMetaData databaseMetaData = conn.getMetaData();
 
        if (databaseMetaData.supportsResultSetType(TYPE_FORWARD_ONLY)) {
            out.print("Supports TYPE_FORWARD_ONLY with ");
            if (databaseMetaData.supportsResultSetConcurrency(TYPE_FORWARD_ONLY, CONCUR_UPDATABLE)) {
                out.println("CONCUR_UPDATABLE");
            } else {
                out.println("CONCUR_READ_ONLY");
            }
        } else {
            out.println("TYPE_FORWARD_ONLY is not supported!");
        }
 
        if (databaseMetaData.supportsResultSetType(TYPE_SCROLL_INSENSITIVE)) {
            out.print("Supports TYPE_SCROLL_INSENSITIVE with ");
            if (databaseMetaData.supportsResultSetConcurrency(TYPE_SCROLL_INSENSITIVE, CONCUR_UPDATABLE)) {
                out.println("CONCUR_UPDATABLE");
            } else {
                out.println("CONCUR_READ_ONLY");
            }
        } else {
            out.println("TYPE_SOCIAL_INSENSITIVE is not supported!");
        }
 
        if (databaseMetaData.supportsResultSetType(TYPE_SCROLL_SENSITIVE)) {
            out.print("Supports TYPE_SCROLL_SENSITIVE with ");
            if (databaseMetaData.supportsResultSetConcurrency(TYPE_SCROLL_SENSITIVE, CONCUR_UPDATABLE)) {
                out.println("CONCUR_UPDATABLE");
            } else {
                out.println("CONCUR_READ_ONLY");
            }
        } else {
            out.println("TYPE_SOCIAL_INSENSITIVE is not supported!");
        }
 
        conn.close();
    }
}

and the output..
Supports TYPE_FORWARD_ONLY with CONCUR_UPDATABLE
Supports TYPE_SCROLL_INSENSITIVE with CONCUR_UPDATABLE
TYPE_SOCIAL_INSENSITIVE is not supported!

Lets remember what these mean..
  • TYPE_FORWARD_ONLY The cursor moves forward only through a set of results.
  • TYPE_SCROLL_INSENSITIVE Cursor position can be moved in the result forward or backward, or positioned to a particular cursor location. Any changes made to the underlying data—the database itself—are not reflected in the ResultSet.
  • TYPE_SCROLL_SENSITIVE Cursor can be changed in the results forward or backward, or positioned to a particular cursor location. Any changes made to the underlying data are reflected in the open result set.
and..
  • CONCUR_READ_ONLY This is the default value for result set concurrency. Any open result set is read-only and cannot be modified or changed.
  • CONCUR_UPDATABLE A result set can be modified through the ResultSet methods while the result set is open.