Oracle DB 是否支持每个连接的多个(并行)操作?

2022-01-24 00:00:00 connection oracle java

我的 Java 应用程序需要将光标保持在 Oracle DB 上一段时间.在此期间,必须进行其他 DB 语句.这需要单独的数据库连接还是可以使用相同的(光标的)?

My Java application needs to hold cursor to Oracle DB for some time. During it other DB statements have to be made. Does this require separate DB connections or same (cursor's one) can be used?

谢谢.

推荐答案

唯一的限制是单个语句在给定时间只能有一个 ResultSet.请注意,一个语句可以生成多个 ResultSet,但您必须按顺序访问它们(使用 getNextResult())

The only restriction is that a single statement can only have a single ResultSet at a given time. Note that a statement can produce multiple ResultSets but you have to access them sequentially (using getNextResult())

为了能够拥有多个打开的结果集/游标,您需要多个 java.sql.Statement 对象.

To be able to have multiple open ResultSets/Cursors you need multiple java.sql.Statement objects.

单个连接只能有一个活动(即正在运行)语句.因此,如果您需要多个打开的游标(结果集),您需要按顺序(一个接一个)运行它们,每个游标都有自己的 Statement 对象.

A single connection can only have a single active (i.e. running) statement. So if you have need multiple open cursors (ResultSets) you need to run them sequentially (one after the other) each with their own Statement object.

相关文章