Michel,

if that's really the case, please make sure that you close them in any case. This has 
to include error conditions as well. E.g. when you try to update data 
in along transaction, and you are hit by an exception (such as 
ObjectModifiedException), please make sure that you call Database.rollback() and 
Database.close() in this case. This functionality could for example be implemented as 
part of a finally clause as follows:

try {

        Database. db = jdo.getDatabase();

        db.begin();

        // do something ...

        db.commit();

}
catch (PersistenceException e) {
        db.rollback();
}
finally {
        db.close();
}

Please be aware that the above code fragment will not compile because of missing 
exception handling, etc. But it should demonstrate a clean usage of 
database connections.

Regards
Werner


On Fri, 23 Jan 2004 17:33:16 -0200, Michel Bertrand wrote:

>Thanks !!! I'm using MySQL ! I will study and implement 
>your solution too ! But essentially the root of my problem 
>was lots of QueryResult's not closed ... 
>
>Thanks again !!!
>Best Regards !!!
>
>-----Mensagem original-----
>De: Stein M. Hugubakken [mailto:[EMAIL PROTECTED]
>Enviada em: sexta-feira, 23 de janeiro de 2004 16:06
>Para: [EMAIL PROTECTED]
>Assunto: Re: [castor-dev] Castor and DBCP question ...
>
>
>Michel Bertrand wrote:
>> Hi !
>> 
>> I'm using Castor and DBCP in my app and I'm having lots of pool exhausted 
>> exceptions. I believe that it happens because I have a lot of processing when
>> showing my app pages. But I'm sure of closing each Castor DB connection after 
>> its use. So, I don't see any reason to the exceptions and another strange
>> thing is that I have this error many times running the app with one single user.
>> 
>> Did you have any hint ? What should I do in this case ? I have to increase the
>> number of connections avaible at the pool ? Should I configure a waiting time ?
>> 
>
>MySQL can display a list of processes (connections) running with "show 
>processlist", what type of database are you using?
>
>You must make sure your're closing your connections and if you want to 
>patch Castor you can try out this fix that logs if connections is not 
>closed by the user:
>http://bugzilla.exolab.org/show_bug.cgi?id=1499
>
>Of course it would help with some code to look at...
>
>This is my setup for Poolman:
><initialConnections>1</initialConnections>
><minimumSize>0</minimumSize>
><maximumSize>99</maximumSize>
><connectionTimeout>3600</connectionTimeout>
><skimmerFrequency>120</skimmerFrequency>
><userTimeout>100</userTimeout>
>
>I've set the connection to be closed after an hour of inactivity, so at 
>the end of day when things calm down at the site resources are cleaned up.
>
>Stein
>
>----------------------------------------------------------- 
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>        unsubscribe castor-dev
>
>----------------------------------------------------------- 
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>        unsubscribe castor-dev
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to