Java ResultSet HOLD_CURSORS_OVER_COMMIT

Syntax

ResultSet.HOLD_CURSORS_OVER_COMMIT has the following syntax.

static final int HOLD_CURSORS_OVER_COMMIT

Example

In the following code shows how to use ResultSet.HOLD_CURSORS_OVER_COMMIT field.


import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
/*from   w w  w . j  a va  2  s .  c  o  m*/
public class Main {
  public static void main(String[] args) throws Exception {
    Connection conn = getConnection();

    DatabaseMetaData dbMeta = conn.getMetaData();
    if (dbMeta.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
      System.out.println("this database hold cursors over commit");
    } else if (dbMeta.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT)) {
      System.out.println("this database close cursors at commit");
    }
    conn.close();

  }

  private static Connection getConnection() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";

    return DriverManager.getConnection(url, "sa", "");
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.sql »




DatabaseMetaData
ParameterMetaData
PreparedStatement
ResultSet
Timestamp