This isn't specific to jOOQ, but is a general rule regarding resources.
Whoever opens a resource must close the resource.

- A Connection is a resource, so you must close both in your first case
- A DataSource isn't a resource. It is used to create resources
(Connections). jOOQ creates these internally, and will close them as
necessary

I hope this helps
Lukas

On Mon, Apr 22, 2024 at 4:14 PM ahmed mustapha ghanmi <
[email protected]> wrote:

> Hello everyone,
>
> If I understand correctly,
> - if i pass a Connection to jooq to create a parsing connection, i need to
> close both the parsing connection and its underlying connection
> - if i pass a data source to jooq, i need to only close the parsing
> connection, jooq handles the underlying connection
> Is that right?
>
> Le mardi 30 mars 2021 à 11:55:06 UTC+2, Walid CHAIB a écrit :
>
>> Hi Lukas,
>> Thanks again, You are alright.
>> Problem solved.
>>
>> Le lun. 29 mars 2021 à 12:26, Lukas Eder <[email protected]> a écrit :
>>
>>> Hi Walid,
>>>
>>> - Whoever opens a JDBC Connection is responsible for closing it again
>>> - Your example is now passing the DataSource to jOOQ, in case of which
>>> jOOQ will open *and* close the connection for you
>>> - However, you also close the underlying (wrapped) JDBC connection
>>> explicitly in closeDbConn. You probably shouldn't do that
>>> - I gave you that particular hint about a possible workaround in
>>> closeDbConn, because at the time, you were passing the *Connection*
>>> (not DataSource) to jOOQ, meaning *you* were opening the connection and
>>> *you* were responsible for closing it again. You cannot, however, close it
>>> via the jOOQ ParsingConnection, because the jOOQ ParsingConnection follows
>>> the jOOQ ConnectionProvider lifecycle, meaning that because you gave jOOQ a
>>> connection which *you* opened, jOOQ is assuming that *you* will close it
>>> again, not jOOQ.
>>>
>>> I don't think there's a new question here, short of perhaps a
>>> misunderstanding of the above.
>>>
>>> If you think there's a bug here somewhere, I'd love to investigate it,
>>> but as I told you, these kinds of issues are very hard to debug by email
>>> snippets. We have a template to create MCVEs (Minimal, Complete, Verifiable
>>> Examples): https://github.com/jOOQ/jOOQ-mcve.
>>>
>>>
>>> On Mon, Mar 29, 2021 at 10:59 AM Walid CHAIB <[email protected]>
>>> wrote:
>>>
>>>> Why when I execute a query with jooq parsing connection I get
>>>> You can see in the attached files the code of the server and the
>>>> connection :
>>>>
>>>> - jOOQ:3.15
>>>> <dependency>
>>>> <groupId>org.jooq.pro</groupId>
>>>> <artifactId>jooq</artifactId>
>>>> <version>3.15.0</version>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>org.jooq.pro</groupId>
>>>> <artifactId>reactivestreams</artifactId>
>>>> <version>3.15.0</version>
>>>> </dependency>
>>>> - Java:8
>>>> - Database :Postgresql
>>>> - OS:open suse
>>>> - JDBC Driver:4.2
>>>>
>>>> --
>>>> 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].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/jooq-user/CAOP4Xxin-Mw6jky9q-3O3pP3Fh6h6hYw3f4pDp%3DaS9x07KRbFg%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/jooq-user/CAOP4Xxin-Mw6jky9q-3O3pP3Fh6h6hYw3f4pDp%3DaS9x07KRbFg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> 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].
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jooq-user/CAB4ELO6%3DKV6QmZiUvp6%3DPtYhZGQScK1rZGYoe_PwQYF47DDa%2Bg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/jooq-user/CAB4ELO6%3DKV6QmZiUvp6%3DPtYhZGQScK1rZGYoe_PwQYF47DDa%2Bg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/c17b0afe-30cd-4158-b07f-c225afd8e5f1n%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/c17b0afe-30cd-4158-b07f-c225afd8e5f1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5pQ_2OgzExR2Yq5A-L3h2RgHqFx9tyxCURA-%3DDii2MZA%40mail.gmail.com.

Reply via email to