db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Holthuizen <patr...@eaze.org>
Subject question: is it possible to use a single connection for multiple threads when auto-commit is on?
Date Sat, 11 Sep 2010 08:31:16 GMT
Hello,

In the Derby documentation I find that there are some restrictions when
using a single connection with multiple threads. For example and especially:

Here is a review of the potential pitfalls of sharing a single
/Connection/ among multiple threads.

    * Committing or rolling back a transaction closes all open
      /ResultSet/ objects and currently executing /Statements/, unless
      you are using held cursors.

      If one thread commits, it closes the /Statements/ and /ResultSets/
      of all other threads using the same connection.


Now wonder if this is also true with auto-commit on? For example:


THREAD 1                                        THREAD 2
PreparedStatement s1 =
    c.prepareStatement("SELECT * FROM T1");
ResultSet rs1 = s1.executeQuery();
rs.next();
...use record

                                                PreparedStatement s2 =
                                                   
c.prepareStatement("UPDATE T1
                                                        SET F1 = "value"
                                                        WHERE F2 =
"anotherValue");

rs.next();
...use record

Do I run into troubles when the second rs.next() is called?

Thank you in advance.

Sincerely,
Patrick Holthuizen

Mime
View raw message