Recent

Author Topic: Repeating trying to create datamodule in FastCGI application  (Read 387 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1523
Repeating trying to create datamodule in FastCGI application
« on: November 08, 2024, 09:04:18 am »
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.
Code: Pascal  [Select][+][-]
  1. type
  2.   Taqfb5 = class(TDataModule, IaqCommon, IDataCollection, IaqEdit)
  3.      fbAQ: TIBConnection;
  4.      trAQ: TSQLTransaction;
  5.      procedure DataModuleCreate(Sender: TObject);
  6.      procedure DataModuleDestroy(Sender: TObject);
  7.      // .....
  8.  
  9.   end;
  10.  
  11. var
  12.    aqfb5 : Taqfb5;
  13.  
  14. implementation
  15.  
  16. procedure Taqfb5.DataModuleCreate(Sender: TObject);
  17. begin
  18.      log('creating');
  19.      fbAQ.Connected := True;
  20.      log('created');
  21. end;
  22.  
  23. procedure Taqfb5.DataModuleDestroy(Sender: TObject);
  24. begin
  25.      log('destroyed');
  26. end;
  27.  
  28.     // .........................
  29.  
  30. initialization
  31.      log('initializing');
  32.      aqfb5 := Taqfb5.create(nil);
  33.  
  34. finalization
  35.      log('finalizing');
  36.      aqfb5.free;
  37. 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...

 

TinyPortal © 2005-2018