Hello Michael,
Thank you for your tip.
I think, I do not use em.close() after very each operation on DB
Should I additionally configure the ConnectionRetainMode property in my
persistence.xml (Suppose not, for on-demand is the default configuration for
ConnectionRetainMode)
Actual version
....
<properties>
<property name="openjpa.TransactionMode" value="managed"/>
<property name="openjpa.ConnectionFactoryMode" value="managed"/>
<property name="openjpa.jdbc.DBDictionary" value="db2"/>
<property name="openjpa.jdbc.Schema" value="T7"/>
</properties>
......
Improved version
....
<properties>
<property name="openjpa.TransactionMode" value="managed"/>
<property name="openjpa.ConnectionFactoryMode" value="managed"/>
<property name="openjpa.ConnectionRetainMode" value="on-demand"/>
<property name="openjpa.jdbc.DBDictionary" value="db2"/>
<property name="openjpa.jdbc.Schema" value="T7"/>
</properties>
....
Annette Scherer
Abteilung Informatik
HUK-COBURG
Bahnhofsplatz
96444 Coburg
Telefon 09561 96-1718
Telefax 09561 96-3671
E-Mail [email protected]
Internet www.HUK.de
=============================================================
HUK-COBURG Haftpflicht-Unterstützungs-Kasse kraftfahrender Beamter Deutschlands
a. G. in Coburg
Reg.-Gericht Coburg HRB 100; St.-Nr. 9212/101/00021
Sitz der Gesellschaft: Bahnhofsplatz, 96444 Coburg
Vorsitzender des Aufsichtsrats: Werner Strohmayr.
Vorstand: Dr. Wolfgang Weiler (Sprecher), Wolfgang Flaßhoff, Stefan Gronbach,
Klaus-Jürgen Heitmann, Dr. Christian Hofer.
=============================================================
-----Ursprüngliche Nachricht-----
Von: Michael Dick [mailto:[email protected]]
Gesendet: Mittwoch, 8. Juli 2009 16:15
An: [email protected]
Betreff: Re: Cloese database connection
Hi Annette,
Are you using container managed EntityManagers, or application managed EMs?
It *sounds* like you the EntityManager isn't being closed.
To answer your specific question the connection is opened the first time you
interact with the database (ie execute a query, or persist an entity). When
it's closed depends on the ConnectionRetainMode setting [1] (looks like
you're using 'always').
[1]
http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/manual/manual.html#ref_guide_dbsetup_retain
HTH
-mike
On Wed, Jul 8, 2009 at 8:12 AM, Scherer, Annette <
[email protected]> wrote:
> Hello,
>
> I am using OpenJPA with managed transactions and connections on an IBM
> WebSphere Application Server.
>
> Extract from persistence.xml:
> <property name="openjpa.TransactionMode" value="managed"/>
> <property name="openjpa.ConnectionFactoryMode" value="managed"/>
>
> Configuration WAS:
> JDBC - datasources - non XA connection
>
>
> When does a managed connection open and when does it close?
> My problem is that many connections will be opened that are never closed
> again. Even if I shut down the Server, the connections remain open.
>
>
> Thank you for help
> Annette Scherer
>
>
> Abteilung Informatik
>
>
>