The spec may not require it, but for Oracle, H2, Derby, Postgres (and I
think MySQL) Connection objects are thread safe as long as you do not try to
do "transaction interleaving", i.e., use one connection for multiple
transactions. In my case I want to run multiple queries in the same
transaction space. It doesn't by me any performance over serializing the
queries, but it buys me a ton of code clarity.

For my purposes, having tested for our supported backends (H2, Postgres,
Oracle), I'm comfortable with it.

Chris

On Wed, Apr 21, 2010 at 2:31 AM, James Gregurich <[email protected]>wrote:

>
> oh...It is H2 that is unusual in this regard? That is good to know.
>
>
> The reason I am asking this is because it is my general policy to never use
> a mutex I don't have to use. Having multiple layers of mutexes is a recipe
> for trouble IMO. I am trying to decide if I should follow the java code and
> add a mutex to JdbcConnection or let client code set up its own mutex to
> protect a shared connection.
>
>
> On Apr 20, 2010, at 10:49 PM, Joonas Pulakka wrote:
>
> > The JDBC spec doesn't require Connection to be thread-safe. But H2's
> > Connection (http://www.h2database.com/javadoc/org/h2/jdbc/
> > JdbcConnection.html) is thread-safe. So yes, it's a kind of weird: as
> > long as you use H2, you'll be fine, but since you're doing it "wrong",
> > you'll lose interchangeability with other databases.
> >
> > Best Regards,
> > Joonas
> >
> > On 21 huhti, 05:41, Chris Schanck <[email protected]> wrote:
> >> The product I work on happily makes use of 100+ threads over 1
> connection in
> >> certain situations where multiple threads are evaluating different data
> >> points which need to have the same transaction visibility. So far, H2 is
> >> decent at this.
> >>
> >> Chris
> >>
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<h2-database%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
>
>


-- 
C. Schanck

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to