Note that there are some explanatory texts on larger screens.

plurals
  1. POjdbc statement connection
    primarykey
    data
    text
    <p>QUESTION: can YOU use multiple statements and recordset, which operate simultaneously, using the same connection in a non MULTI THREAD?</p> <p>I only found this question which interests me, but the answer is not consistent.</p> <p><a href="https://stackoverflow.com/questions/5149135/jdbc-statement-preparedstatement-per-connection">JDBC Statement/PreparedStatement per connection</a></p> <p>The answer explain the relationship between recordset and statement, which is known to me.</p> <p>Given that, you can not have multiple recordsets for statement</p> <p>The answer says that you can have multiple recordsets for connection. But they are not mentioned any other sources.</p> <hr> <p><strong>I'm asking if it's possible to loop over the first recordset, then using the same connection (used to generate first recordset) to open another recordset use it looping in iteration. And where is the documentation that define this behavior?</strong></p> <hr> <p>The situation that interests me is like this, the statement perform tasks simultaneously ins</p> <pre><code>Connection con = Factory.getDBConn (user, pss, endpoint, etc); Statement stmt = con.createStatement (); ResultSet rs = stmt.executeQuery ("SELECT TEXT FROM dba"); while (rs.next ()) { rs.getInt (.... rs.getInt (.... rs.getInt (.... rs.getInt (.... Statement stmt2 con.createStatement = (); ResultSet rs2 = stmt2.executeQuery ("iSelect ......"); while (rs2.next ()) { .... rs2.close (); stm2.close (); Statement stmt3 con.createStatement = (); ResultSet rs3 = stmt3.executeQuery ("Insert Into table xxx ......"); .... rs3.close (); stm3.close (); } </code></pre> <hr> <p>To clarify a bit more: with the execution of update in stmt3, you could obtain an error like this:</p> <p>java.sql.SQLException: There is an open result set on the current connection, which must be closed prior to executing a query.</p> <p>So you can't mix SQL in the same connection.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload