Subject Re: Client FBWrappingDS or DriverManager
Author Roman Rokytskyy
Hi,

> I have been looking into the difference between using
>
> DriverManager.getConnection();
> and
> FDWrappingDataSource.getConnection();
>
> in client apps.
>
> From my reading DataSource is the preferred way to get a connection
> instead of using DriverManager.getConnection();
>
> Especially in server side apps, but what about Client side.

DataSource increases portability. If your code is designed so, that
it can take JDBC connection from DataSource, you will have no
problems of changing the underlying implementation of the DataSource
to provide you some more features (connection pooling, switching to
another database server if primary one failed, etc.).

> Does one introduce more overhead than the other?

No. At least in JayBird's case. FBWrappingDataSource and FBDriver
both use FBDataSource to obtain connections.

> Is one preferred over the other on the client side?

FBWrappingDataSource uses pooling connection manager if pooling is
enabled, FBDriver uses standalone connection manager in all cases. If
you need connection pooling, FBWrappingDataSource is preferred,
otherwise they are equivalent.

> I am asking from a single thread app, using a single connection to
> the db at the moment.

Traditionally DriverManager approach is widely used in the client
application (it is easier to write DriverManager.getConnection(url,
user, passwd) than to instantiate DataSource). I prefer DataSource,
but it should make no difference in your case. In case of server-side
components running in some container you do not have too many
choices. Container provides you DataSource instance bound in JNDI.

Best regards,
Roman Rokytskyy