Hi,
> a private per-thread database
There is nothing like a "per-thread database". My guess is what you mean is
"in-memory private".
Each time you open a connection using the exact database URL
"jdbc:h2:mem:", you will get a new database ("in-memory private"). It
doesn't matter if that's within the same process or thread or not.
Each time you open a connection using the database URL "jdbc:h2:mem:test"
or similar (that is, something after "mem:"), you will get _the same_
database within the same classloader if you use the same name. This again
doesn't depend on the thread.
For details, see:
http://h2database.com/html/features.html#database_url
http://h2database.com/html/features.html#in_memory_databases
Regards,
Thomas
On Thu, Jan 2, 2014 at 8:53 PM, Laird Nelson <[email protected]> wrote:
> On Monday, December 30, 2013 5:38:46 PM UTC-8, Kartweel wrote:
>>
>> It will be 2.
>>
>
> Thanks.
>
>
>> and the second create table will fail because the table already exists.
>>
>
> Yep; thanks.
>
>
>> But I don't see how that has anything to do with being thread safe?
>>
>
> I'm sure I worded it badly. I am trying to see how best to run parallel
> unit tests using the
> maven-surefire-plugin,<http://lairdnelson.wordpress.com/2013/09/25/concurrent-testing/>where
> you can control parallelism at the process and thread level. I
> didn't see anything in the H2 documentation about whether a "mem"
> database was one-per-process or one-per-thread.
>
>
>> The in memory database is per process, so all threads access the same
>> database.
>>
>
> Thank you; this is what I was looking for. Is there a spot in the
> documentation that says this explicitly?
>
>
>> If you want a separate database per thread then give the databases
>> different names.
>>
>
> That has been my approach so far; it dawned on me (wrongly, as it turns
> out) that perhaps I was overengineering something—that perhaps jdbc:h2:mem
> was enough for a private per-thread database, but as you point out it is
> not. Thanks for your time and the clarity of your response.
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.