You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Mariusz Sieraczkiewicz <ma...@stud.ics.p.lodz.pl> on 2003/11/27 22:27:27 UTC
Database connection from flowscript
I asked the question about getting jdbc connection from flowscript on user
mailing list
some time ago, but there was no answer. I started digging, but had some
problems.
I'm having code like this:
//////////////////////
var dbSelector =
cocoon.getComponent(Packages.org.apache.avalon.excalibur.datasource.DataSourceComponent.ROLE
+ "Selector");
try {
var dataSrc = dbSelector.select(srcName);
conn = dataSrc.getConnection();
}
catch (e) {
e.printStackTrace();
}
finally {
if (conn != null) {
conn.close();
conn = null;
}
if (dbSelector != null) {
cocoon.releaseComponent(dbSelector);
dbSelector = null;
}
}
///////////////
Using it I'm experiencing pooled connection out of resources
after several calls (page using it just hungs).
I'm afraid I'm not realeasing all resources properly. What's wrong?
Re: Database connection from flowscript
Posted by Matthias Stöckel <Ma...@fztig938.bank.dresdner.net>.
Joerg Heinicke wrote:
> On 28.11.2003 13:32, Matthias Stöckel wrote:
>
>> Hi Mariusz,
>>
>> we encountered the same problem. Our case was a little bit different,
>> but the results were definitely the same (>1500 open connection on the
>> DB).
>> I think the problem is that the connection will only being returned to
>> the pool, as soon as the continuation object gets destroyed, and that
>> can take some time depending on your configuration. I haven't looked
>> into the code yet, so this is only an assumption.
>
>
> Hmm, I wonder how it should be related to continuations. In Mariusz code
> below there is no sendPage(AndWait)() and so no continuation involved.
I don't know if Mariusz used continuation in his code, but in my example
below I used the sendPage function and therefore a Continuation object
is involved.
>> Perhaps one of the commiters can jump in here and help a little bit.
>> If I have the following flow code, I would assume that the 'schandler'
>> object is not any longer referenced and can be finalized as soon as I
>> set it to 'null'. Unfortunately this will not happen.
>> Is this a bug, or is there something wrong with the code?
>
>
> I can't see what's wrong, but I'm not that expert.
>
>> var schandler=new
>> Packages.xyz.ClientHandler(getSelectedClients(),connection);
>> ...
>> schandler=null;
>>
>>
Matthias
Re: Database connection from flowscript
Posted by Joerg Heinicke <jo...@gmx.de>.
On 28.11.2003 13:32, Matthias Stöckel wrote:
> Hi Mariusz,
>
> we encountered the same problem. Our case was a little bit different,
> but the results were definitely the same (>1500 open connection on the DB).
> I think the problem is that the connection will only being returned to
> the pool, as soon as the continuation object gets destroyed, and that
> can take some time depending on your configuration. I haven't looked
> into the code yet, so this is only an assumption.
Hmm, I wonder how it should be related to continuations. In Mariusz code
below there is no sendPage(AndWait)() and so no continuation involved.
> Perhaps one of the commiters can jump in here and help a little bit. If
> I have the following flow code, I would assume that the 'schandler'
> object is not any longer referenced and can be finalized as soon as I
> set it to 'null'. Unfortunately this will not happen.
> Is this a bug, or is there something wrong with the code?
I can't see what's wrong, but I'm not that expert.
> var schandler=new
> Packages.xyz.ClientHandler(getSelectedClients(),connection);
> ...
> schandler=null;
>
>
> Mariusz Sieraczkiewicz wrote:
>
>> I asked the question about getting jdbc connection from flowscript on
>> user mailing list
>> some time ago, but there was no answer. I started digging, but had some
>> problems.
>> I'm having code like this:
>> //////////////////////
>> var dbSelector =
>> cocoon.getComponent(Packages.org.apache.avalon.excalibur.datasource.DataSourceComponent.ROLE
>> + "Selector");
>> try {
>> var dataSrc = dbSelector.select(srcName);
>> conn = dataSrc.getConnection();
>> }
>> catch (e) {
>> e.printStackTrace();
>> }
>> finally {
>> if (conn != null) {
>> conn.close();
>> conn = null;
>> }
>> if (dbSelector != null) {
>> cocoon.releaseComponent(dbSelector);
>> dbSelector = null;
>> }
>> }
>> ///////////////
>>
>> Using it I'm experiencing pooled connection out of resources
>> after several calls (page using it just hungs).
>> I'm afraid I'm not realeasing all resources properly. What's wrong?
Joerg
Re: Database connection from flowscript
Posted by Matthias Stöckel <Ma...@fztig938.bank.dresdner.net>.
Hi Mariusz,
we encountered the same problem. Our case was a little bit different,
but the results were definitely the same (>1500 open connection on the DB).
I think the problem is that the connection will only being returned to
the pool, as soon as the continuation object gets destroyed, and that
can take some time depending on your configuration. I haven't looked
into the code yet, so this is only an assumption.
Perhaps one of the commiters can jump in here and help a little bit. If
I have the following flow code, I would assume that the 'schandler'
object is not any longer referenced and can be finalized as soon as I
set it to 'null'. Unfortunately this will not happen.
Is this a bug, or is there something wrong with the code?
Cheers,
Matthias
var schandler=new
Packages.xyz.ClientHandler(getSelectedClients(),connection);
...
schandler=null;
Mariusz Sieraczkiewicz wrote:
> I asked the question about getting jdbc connection from flowscript on
> user mailing list
> some time ago, but there was no answer. I started digging, but had some
> problems.
> I'm having code like this:
> //////////////////////
> var dbSelector =
> cocoon.getComponent(Packages.org.apache.avalon.excalibur.datasource.DataSourceComponent.ROLE
> + "Selector");
> try {
> var dataSrc = dbSelector.select(srcName);
> conn = dataSrc.getConnection();
> }
> catch (e) {
> e.printStackTrace();
> }
> finally {
> if (conn != null) {
> conn.close();
> conn = null;
> }
> if (dbSelector != null) {
> cocoon.releaseComponent(dbSelector);
> dbSelector = null;
> }
> }
> ///////////////
>
> Using it I'm experiencing pooled connection out of resources
> after several calls (page using it just hungs).
> I'm afraid I'm not realeasing all resources properly. What's wrong?
>