gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 08:46:35 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com