RE: Closing ODMG JDBC Connection

2004-01-28 Thread Coup, Robert Muir
Hi Lance,

Pools are great and I don't really want to get rid of that by using
ConnectionFactoryNotPooledImpl. However, I found part of the answer.
Each of the ConnectionFactory's has a releaseAllResources method which
will close all the connections in the pool (exactly what I want). 

Anyway, after much mailing list searching and code reading this seems to
work...

PersistenceBroker broker 
   =
PersistenceBrokerFactory.createPersistenceBroker(((DatabaseImpl)OJB.getI
nstance().getDatabase(null)).getPBKey());
((ConnectionManagerImpl)broker.serviceConnectionManager()).getUnderlying
ConnectionFactory().releaseAllResources();
OJB.getInstance().getDatabase(null).close();

Relatively nasty... Maybe it should go in the faq or there should be an
easier way of getting to it (there probably is - how?)

Thanks for your help,

Rob :)


> -Original Message-
> From: Lance Eason [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 29 January 2004 12:19 p.m.
> To: OJB Users List
> Subject: RE: Closing ODMG JDBC Connection
> 
> 
> Not closing the connection is kind of the whole point of 
> connection pooling, and OJB provides connection pooling.  
> Database connections are typically expensive to establish, so 
> rather than each time you use the database creating a new 
> connection and then releasing it at the end connections are 
> maintained in a pool and just borrowed for a period of time 
> and then returned so other clients can use them. It looks 
> like you can specify different connection pooling 
> implementations though so what you want is probably to set 
> the following in OJB.properties:
> 
> ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.Conne
> ctionFactoryNotPooledImpl
> 
> -Original Message-
> From: Coup, Robert Muir [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 28, 2004 5:08 PM
> To: [EMAIL PROTECTED]
> Subject: Closing ODMG JDBC Connection
> 
> 
> Hi All,
> 
> We're using a hsqldb database for part of our application, 
> and need to package the database files up into a zip archive 
> before exiting. Problem is, OJB doesn't seem to be closing 
> the database connection so the files are still locked and we 
> can't delete them once they are in the Zip file.
> 
> We use a single db reference throughout out application, 
> initialised by
>   db = OJB.getInstance().newDatabase(null);
> When we go to shut it down, we call
>   db.close();
> 
> Are we missing some obvious step, or do we need to start 
> playing with finalize()? I have tested that hsqldb releases 
> the file locks when the jdbc connection is closed via a call 
> to connection.close().
> 
> Thanks for your help,
> Rob :)
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Closing ODMG JDBC Connection

2004-01-28 Thread Lance Eason
Not closing the connection is kind of the whole point of connection pooling, and OJB 
provides connection pooling.  Database connections are typically expensive to 
establish, so rather than each time you use the database creating a new connection and 
then releasing it at the end connections are maintained in a pool and just borrowed 
for a period of time and then returned so other clients can use them. It looks like 
you can specify different connection pooling implementations though so what you want 
is probably to set the following in OJB.properties:

ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl

-Original Message-
From: Coup, Robert Muir [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 28, 2004 5:08 PM
To: [EMAIL PROTECTED]
Subject: Closing ODMG JDBC Connection


Hi All,

We're using a hsqldb database for part of our application, and need to
package the database files up into a zip archive before exiting. Problem
is, OJB doesn't seem to be closing the database connection so the files
are still locked and we can't delete them once they are in the Zip file.

We use a single db reference throughout out application, initialised by
db = OJB.getInstance().newDatabase(null);
When we go to shut it down, we call
db.close();

Are we missing some obvious step, or do we need to start playing with
finalize()? I have tested that hsqldb releases the file locks when the
jdbc connection is closed via a call to connection.close().

Thanks for your help,
Rob :)

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Closing ODMG JDBC Connection

2004-01-28 Thread Coup, Robert Muir
Hi All,

We're using a hsqldb database for part of our application, and need to
package the database files up into a zip archive before exiting. Problem
is, OJB doesn't seem to be closing the database connection so the files
are still locked and we can't delete them once they are in the Zip file.

We use a single db reference throughout out application, initialised by
db = OJB.getInstance().newDatabase(null);
When we go to shut it down, we call
db.close();

Are we missing some obvious step, or do we need to start playing with
finalize()? I have tested that hsqldb releases the file locks when the
jdbc connection is closed via a call to connection.close().

Thanks for your help,
Rob :)

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]