You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Daniel Perry <d....@netcase.co.uk> on 2004/01/08 18:20:06 UTC

ConnectionFactoryPooledImpl -> releaseAllResources

The releaseAllResources method in ConnectionFactoryPooledImpl is not
releaseing database connections.

I've been trying to debug it, but dont understand how the objectpool works,
and am now stumped.

This is causing big problems for my app as i have an embedded hsqldb which
needs to be released so another app can connect to it.

Thanks for any help,

Daniel.


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: ConnectionFactoryPooledImpl -> releaseAllResources

Posted by Daniel Perry <d....@netcase.co.uk>.
> this will not work, because this creates a new ConnectionFactory instance.

>From what i can make out, ConnectionFactoryFactory will always return the
same ConnectionFactory instance as it only creates a new 'singleton'
ConnectionFactoryFactory if static singleton is null, and then only creates
a new conFactory if singleton.conFactory is null.

> I'm not sure what's the problem in your case, but I think it's OJB. The
> connection/pooling stuff needs some refactoring before 1.1 ;-)

I think so too. I've removed all persistent objects from the session (bad
practice i guess to do it anyway).  The problem is persisting.

I tried the alternative code you suggested.  The same problem happens.

One thing that i am a little confused by is that there are two parts to the
system.  The closing of database works fine from the back end, but fails
from the front end!  Both use the same base classes for calling OJB.

Ah well, i shall continue my debugging tomorrow.

Daniel.


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: ConnectionFactoryPooledImpl -> releaseAllResources - STRUTS+OJB+HSQLDB embedded developers may find this useful

Posted by Daniel Perry <d....@netcase.co.uk>.
I've now bodged the ConnectionFactoryPooledImpl so that it monitors all jdbc
connections created, and releaseAllResources() now kills any unclosed
connections.

Probably not going to affect anyone not using hsqldb embedded (or any other
database that can only be opened once at a time).  One side effect is that
stoping a tomcat application closes the database! no more reloading tomcat!

If anyone wants the bodged source or jar library, let me know.

Daniel.


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: ConnectionFactoryPooledImpl -> releaseAllResources

Posted by Daniel Perry <d....@netcase.co.uk>.
After adding some lots of "System.out.println"s to
ConnectionFactoryPooledImpl, it would appear that somewhere OJB is not
returning a connection to the pool.  When releaseAllResources() is called,
it calls close() on the GenericObjectPool.  When this happens,
GenericObjectPool has one active connection, and one idle.  It only calls
the destroyObject method (inner class ConPoolFactory) on idle objects.
Active objects are ignored.

Is there any way of finding what is keeping this active connection?
Any way of forcing all connections to be released?

I would have expected PersistenceBrokerFactory.releaseAllInstances(); to
release all conections back to the pool.

I think for a bodge i might have to add a static list somwhere and record
references to all connections created in ConPoolFactory.  Then in
releaseAllResources() add somthing to kill any connections which are not
closed.

Thanks for any help,
Daniel.


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: ConnectionFactoryPooledImpl -> releaseAllResources

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Daniel,

I'm not sure what's the problem in your case, but I think it's OJB. The 
connection/pooling stuff needs some refactoring before 1.1 ;-)

In your previous mail you said

 > Now, to get at the connection factory i use:
 >
 > ConnectionFactoryFactory.getInstance().createConnectionFactory()
 >
 > Although the method is called create - it doesnt create one if one 
has already been created.
 >
 >>From what i can make out of ConnectionFactoryPooledImpl, 
releaseAllResources() should release all connections.
 >

this will not work, because this creates a new ConnectionFactory instance.

You can try to do the following workaround (maybe there is a typo, I 
don't check this):
((ConnectionManagerImpl)broker.serviceConnectionManager()).getUnderlyingConnectionFactory().releaseAllResources()

This should free all connections of the associated DB.

regards,
Armin


Daniel Perry wrote:

> AHHHHHHH going mad.
> I think i know what's happeneing. I dont think there's a problem with OJB
> afterall.....
> 
> I'm storing objects with proxied collections in an HTTPSession.  Am i right
> in thinking that these will have references that will cause the database to
> maintain connections even if the connection pool is closed?
> 
> Thanks,
> Daniel.
> 
> ----- Original Message ----- 
> From: "Daniel Perry" <d....@netcase.co.uk>
> To: "OJB Users List" <oj...@db.apache.org>
> Sent: Thursday, January 08, 2004 5:20 PM
> Subject: ConnectionFactoryPooledImpl -> releaseAllResources
> 
> 
> 
>>The releaseAllResources method in ConnectionFactoryPooledImpl is not
>>releaseing database connections.
>>
>>I've been trying to debug it, but dont understand how the objectpool
> 
> works,
> 
>>and am now stumped.
>>
>>This is causing big problems for my app as i have an embedded hsqldb which
>>needs to be released so another app can connect to it.
>>
>>Thanks for any help,
>>
>>Daniel.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: ConnectionFactoryPooledImpl -> releaseAllResources

Posted by Daniel Perry <d....@netcase.co.uk>.
AHHHHHHH going mad.
I think i know what's happeneing. I dont think there's a problem with OJB
afterall.....

I'm storing objects with proxied collections in an HTTPSession.  Am i right
in thinking that these will have references that will cause the database to
maintain connections even if the connection pool is closed?

Thanks,
Daniel.

----- Original Message ----- 
From: "Daniel Perry" <d....@netcase.co.uk>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Thursday, January 08, 2004 5:20 PM
Subject: ConnectionFactoryPooledImpl -> releaseAllResources


> The releaseAllResources method in ConnectionFactoryPooledImpl is not
> releaseing database connections.
>
> I've been trying to debug it, but dont understand how the objectpool
works,
> and am now stumped.
>
> This is causing big problems for my app as i have an embedded hsqldb which
> needs to be released so another app can connect to it.
>
> Thanks for any help,
>
> Daniel.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org