I have written a FCGI application, with two Webmodules and one Datamodule.
The Database is maintained in the DataModule, and WebModules handle requests.
The skeleton structure of DataModule is as follows.
type
Taqfb5 = class(TDataModule, IaqCommon, IDataCollection, IaqEdit)
fbAQ: TIBConnection;
trAQ: TSQLTransaction;
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
// .....
end;
var
aqfb5 : Taqfb5;
implementation
procedure Taqfb5.DataModuleCreate(Sender: TObject);
begin
log('creating');
fbAQ.Connected := True;
log('created');
end;
procedure Taqfb5.DataModuleDestroy(Sender: TObject);
begin
log('destroyed');
end;
// .........................
initialization
log('initializing');
aqfb5 := Taqfb5.create(nil);
finalization
log('finalizing');
aqfb5.free;
end.
The "log" procedure in above codes simply appends the string to a designated (text) log file. So I can read them.
The key is, when I WRONGLY put Database name of fbAQ, which is an IBConnection, then this application repeats
initializing
creating
destroyed
initializing
creating
destroyed
........unfinished. When I changed the database name correctly the phenomenon disappeared.
So... should I use try..except or try..finally block at the database connection? But what can I do if the DB is not connected? Sending out message "DB not connected" at every request? Hmmm...