Connection.createStatement()
has no parameters. Then we call Statement.executeQuery()
to retrieve data.
Can we use single Statement
instance for multiple different queries run?
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.
如果要执行,则可以使用不同参数的相同SQL。
尝试声明createStatement(int resultSetType,int resultSetConcurrency,int resultSetHoldability)resultSetHoldability = ResultSet.HOLD_CURSORS_OVER_COMMIT
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.