java - JDBC 结果集类型滚动敏感

标签 java jdbc

ResultSet.TYPE_SCROLL_SENSITIVE怎么样?实际上可以在 JDBC 中工作吗?

Statement stmt = conn.createStatement(
                       ResultSet.TYPE_SCROLL_SENSITIVE,
                       ResultSet.CONCUR_READ_ONLY);`

最佳答案

JDBC specification说:

The type of a ResultSet object determines the level of its functionality in two main areas: (1) the ways in which the cursor can be manipulated and (2) how concurrent changes made to the underlying data source are reflected by the ResultSet object. The latter is called the sensitivity of the ResultSet object.

The three different ResultSet types are described below.

[...]

3. TYPE_SCROLL_SENSITIVE

  • The result set is scrollable; its cursor can move both forward and backward relative to the current position, and it can move to an absolute position.
  • The result set reflects changes made to the underlying data source while the result set remains open.

The default ResultSet type is TYPE_FORWARD_ONLY.

The method DatabaseMetaData.supportsResultSetType returns true if the specified type is supported by the driver and false otherwise.

If the driver does not support the type supplied to the methods createStatement, prepareStatement, or prepareCall, it generates an SQLWarning on the Connection object that is creating the statement. When the statement is executed, the driver returns a ResultSet object of a type that most closely matches the requested type. An application can find out the type of a ResultSet object by calling the method ResultSet.getType.

关于java - JDBC 结果集类型滚动敏感,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42622929/

相关文章:

java - 如何将一种方法的结果作为另一种方法的参数

java - Wicket - 如何通过其流下载文件?

java - 线程在 JDBC Teradata 请求上永久挂起

java - 编译错误不兼容类型: java. sql.Connection无法转换为Connection

oracle - 使用 JDBC 捕获和处理 ORA-00001 SQLException 的正确方法是什么?

java - 如何从我的程序创建可执行 jar 文件,以便通过双击或从命令行运行它?

java 游荡和垃圾收集

java - java中如何返回父类

jdbc - 使用CDH4+Cloudera Manager时JDBC驱动放在哪里?

java.io.NotSerializedException 错误