Subject Re: [Firebird-Java] Closing FBWrappingDataSource
Author Roman Rokytskyy
> I have some code which seems to do connection pooling correctly, but
> I have a relatively simple question: how do you close the connection pool,
> i.e. release all cached connections, including related Java and
> database resources.

FBConnectionPoolDataSource has shutdown() method. FBWrappingDataSource that
wraps it does not have such method in all versions including RC4 (it will be
there in release). However shutdown() is automatically called in finalize()
call, so just simply forget the instance and garbage collector will do this
automatically.

If you want to be 100% sure that connections are released and you cannot
wait till release, switch to the FBConnectionPoolDataSource. It has same
interface (in release they both will implement FirebirdPool interface) so
the change is almost trivial:

You had something like that:

FBWrappingDataSource ds = new FBWrappingDataSource();
ds.setXXX
...
Connection con = ds.getConnection();

New code would look like this:

FBConnectionPoolDataSource pool = new FBConnectionPoolDataSource();
pool.setXXXX
...
DataSource ds = new SimpleDataSource(pool);
Connection con = ds.getConnection();

> This is not part of the DataSource interface, for some reason. I tried
> setting the maxPoolSize to 0, but that gave me a divide by 0 error.

Hmmm... Can you tell the line number where it happens? Class is no designed
to allow changing properties on the fly (in most cases this does not affect
its behavior), but divide by 0 error should not happen in any case.

Roman