简体   繁体   English

JDBC中具有单个语句的多个结果集

[英]Multiple ResultSet-s with single Statements in JDBC

Connection.createStatement() has no parameters. Connection.createStatement()没有参数。 Then we call Statement.executeQuery() to retrieve data. 然后,我们调用Statement.executeQuery()检索数据。

Can we use single Statement instance for multiple different queries run? 我们可以将单个Statement实例用于多个不同的查询运行吗?

Yes, but not concurrently. 是的,但不能同时使用。 When you re-execute the statement, the previous result set is closed : 当您重新执行该语句时, 先前的结果集将关闭

A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results. 当关闭,重新执行或用于生成多个结果序列中的下一个结果的Statement对象时,将自动关闭ResultSet对象。

如果要执行,则可以使用不同参数的相同SQL。

尝试声明createStatement(int resultSetType,int resultSetConcurrency,int resultSetHoldability)resultSetHoldability = ResultSet.HOLD_CURSORS_OVER_COMMIT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM