Alright, it's now much clearer to me what is required in multi-threaded 
situations with JDBC.
Thanks.

On Tuesday, April 17, 2012 11:22:56 AM UTC+2, Noel Grandin wrote:
>
>  The problem is that the data is stored on a per-session basis, not on a 
> per-table basis.
>
> In general, JDBC is not guaranteed to be thread-safe, so calling the same 
> connection from multiple threads is going to cause you more problems 
> elsewhere eventually.
>
> I seriously suggest you use a connection pool.
>
> On 2012-04-17 11:18, Thomas wrote: 
>
> Understood. 
> So I'm currently synchronizing the methods that modify this particular 
> table. (It would make perfect sense to have concurrency issues without 
> this).
> Multiple concurrent reads shouldn't be an issue I presume, or do these 
> also require locking and is that causing my issue?
>
> Thanks.
>
> On Tuesday, April 17, 2012 11:14:33 AM UTC+2, Noel Grandin wrote: 
>>
>>  If you are sharing a session/connection between 2 threads, and two of 
>> those threads try to execute statements at the same time, then you might 
>> see this kind of problem.
>>
>> You probably need to either (a) use a connection pool or (b) synchronise 
>> your entire access to the DB.
>>
>> On 2012-04-17 11:05, Thomas wrote: 
>>
>>         Class.forName("org.h2.Driver");
>>         this.con = DriverManager.getConnection("jdbc:h2:"+dbname, "sa", 
>> "");
>>         con.setAutoCommit(true);
>>
>> I just set it once when getting the connection.
>> That's it, nothing fancy.
>>
>> Op dinsdag 17 april 2012 11:00:30 UTC+2 schreef Noel Grandin het 
>> volgende: 
>>>
>>> What does your JDBC URL looks like?
>>> ie. what parameters are you using.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "H2 Database" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/h2-database/-/93IGWW7-65sJ.
>> 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.
>>
>>  -- 
> You received this message because you are subscribed to the Google Groups 
> "H2 Database" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/h2-database/-/16KF_dXhg5EJ.
> 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.
>
>  

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/XIJ8b1MZq5YJ.
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