Subject | Re: connection pooling question |
---|---|
Author | Roman Rokytskyy <rrokytskyy@yahoo.co.uk> |
Post date | 2003-01-28T12:49:10Z |
> Since I have a dialog, where user must supply it's conenction stringIf the connection by a FBWrappingDataSource cannot be established
> (I have one username/pass for all users to conenct to DB, I
> maintain security on application level)
> What happens if user does not supply correct path... will driver
> stay in memory, and must I only call
> org.firebirdsql.jdbc.FBWrappingDataSource setDatabaseName(path)
> again and then call it's getConnection method to achive connection
> if user have entered correct data, or I must unload the driver
> somehow (frankly I cannot find
> org.firebirdsql.jdbc.FBWrappingDataSource API anywhere).
> I have implemented this pool as a Singleton (if this helps).
(for example, incorrect url or credentials), you simply "forget" that
instance of FBWrappingDataSource and it will be automatically garbage
collected by Java. I am not sure that you can re-submit database path
for the same FBWrappingDataSource object, most likely no, since it is
not clear what to do with old connections that were opened with
previous path.
If you need new connection string/credentials, you create new
FBWrappingDataSource instance. You can "forget" old one, but it will
be garbage collected only when all connections obtained from that old
data source are not reachable in terms of garbage collection.
To "forget an object" means that there should be no hard reference on
that object or any object this object is linked with. Typical chain
of references is Statement(*)<->(1)Connection(*)<->(1)DataSource. So,
in order to "forget" a FBWrappingDataSource you must have no hard
reference on any Connection obtained from it and any Statement
obtained from any of the above mentioned connections.
Best regards,
Roman Rokytskyy