Thanks Lukas.

On Sunday, November 10, 2013 4:20:45 PM UTC+8, Lukas Eder wrote:
>
> Hello,
>
> 2013/11/5 <[email protected] <javascript:>>
>
>> Ah sorry, its my bad, what I meant was I'm using 
>> org.apache.tomcat.jdbc.pool.DataSource and it's would be releasing 
>> connection from the pool for each getConnection() request on Datasource, 
>> (hence the 'indirect' threadsafe connection)
>>
>> DSLContext db = DSL.using(dataSource, SQLDialect.POSTGRES);
>>
>> I've had a look at DataSourceConnectionProvider.java and the acquire() is 
>> getting the connection from datasource (which is eventually gets separate 
>> connection for each thread from the pool).
>>
>>             try {
>>                 connection = dataSource.getConnection();
>>             }
>>             catch (SQLException e) {
>>                 throw new DataAccessException("Error getting connection 
>> from data source " + dataSource, e);
>>             }
>>
>> So do you see any threading issues if I share the above DSLContext 'db' 
>> (which is created with a thread-safe datasource) between threads?
>>
>
> People have used shared DSLContext instances before. Yes, there are lots 
> of "potential" threading issues. Once you share DSLContext, your client 
> code must ensure that DSLContext's contained Configuration and Settings 
> will never be changed again.
>
> If you can ensure this, then you can share DSLContext.
>
> Cheers
> Lukas
>  
>
>> Thanks
>> Aym
>>
>> On Tuesday, November 5, 2013 6:47:44 PM UTC+8, Lukas Eder wrote:
>>
>>> Note, I meant to say that DSLContext is not explicitly thread-safe. You 
>>> *can* however achieve a thread-safe environment by carefully implementing 
>>> ConnectionProvider and possibly other SPI types that are used by 
>>> org.jooq.Configuration
>>>
>>>
>>> 2013/11/5 Lukas Eder <[email protected]>
>>>
>>>>  Hi Aym,
>>>>
>>>> No it is not thread-safe, much like the underlying Connection is hardly 
>>>> threadsafe in most transaction / data source contexts (what are you using 
>>>> to make Connection thread-safe?)
>>>>
>>>> Here are a couple of interesting reads on the jOOQ user group about 
>>>> DSLContext / Configuration thread-unsafety:
>>>>
>>>> - https://groups.google.com/d/msg/jooq-user/Y_tfF_eaxKM/jINIU3RYmiYJ
>>>> - https://groups.google.com/d/msg/jooq-user/iomrnfK9cws/QFVH7Ts2iEcJ
>>>> - 
>>>> https://groups.google.com/d/msg/jooq-user/OW58UXvljhU/NDTqFasaJv0J<https://groups.google.com/forum/#!msg/jooq-user/OW58UXvljhU/NDTqFasaJv0J>
>>>>
>>>> Cheers
>>>> Lukas
>>>>
>>>>
>>>> 2013/11/5 <[email protected]>
>>>>
>>>> Hello,
>>>>>
>>>>> Sorry if this is obvious, but is DSLContext created from 
>>>>> DSL.using(DataSource) threadsafe (given datasource and underlying 
>>>>> connection is threadsafe) ?
>>>>>
>>>>> Cheers
>>>>> Aym
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "jOOQ User Group" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>>
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>
>>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to