Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The same connection object can be used to create multiple statement objects and these statement objects can then used by different threads concurrently. Most modern DBs interfaced by JDBC can do that. The JDBC is thus able to make use of concurrent cursors as follows. PostgreSQL is no exception here, see for example:</p> <p><a href="http://doc.postgresintl.com/jdbc/ch10.html" rel="nofollow">http://doc.postgresintl.com/jdbc/ch10.html</a></p> <p>This allows connection pooling where the connection are only used for a short time, namely to created the statement object and but after that returned to the pool. This short time pooling is only recommended when the JDBC connection does also parallelization of statement operations, otherwise normal connection pooling might show better results. Anyhow the thread can continue work with the statement object and close it later, but not the connection. </p> <pre><code>1. Thread 1 opens statement 3. Thread 2 opens statement 4. Thread 1 does something Thread 2 does something 5. ... ... 6. Thread 1 closes statement ... 7. Thread 2 closes statement </code></pre> <p>The above only works in auto commit mode. If transactions are needed there is still no need to tie the transaction to a thread. You can just partition the pooling along the transactions that is all and use the same approach as above. But this is only needed not because of some socket connection limitation but because the JDBC then equates the session ID with the transaction ID.</p> <p>If I remember well there should be APIs and products around with a less simplistic design, where teh session ID and the transaction ID are not equated. In this APIs you could write your server with one single database connection object, even when it does transactions. Will need to check and tell you later what this APIs and products are.</p>
 

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