How to use TSessions for database access in INDY HTTP SERVER
Posted on 2006-06-10
I would just like to know the right way to do this:
1. i am using delphi 7
2. i made a web server application using the INDY HTTP SERVER component.
3. everytime a client accesses the web server application, the application will have to access and update a firebird database (odbc), which is done inside the OnCommandGet event of the IdHTTPServer; Here, many users may access the database simultaneously.
4. i believe that the right way to do this is by using database sessions (TSession).
1. As this application is multithreaded were clients may connect simultaneously, could a datamodule containing queries and stored procedures (created at design time) be used with unique DATABASE sessions (TSession)?
2. OR, should we just create a new DATABASE session (TSession) and the databases, queries and stored procedures components dynamically (runtime) in the OnCommandGet event in the IdHTTPServer?
3. In the OnCommandGet event, should the database be opened everytime a client connects with a new HTTP session?
4. In the OnCommandGet event, should the database be closed after processing and giving a response to the client?
5. Or should the database be closed only when the client ends the HTTP session?
6. When do we free the TSessions created?
NOTE: the HTTP SESSION is different from the database TSESSION
You may answer my questions by giving me a DELPHI SAMPLE CODE.
Thank you very much for your help,