Is it safe to access a database connection in a TIdTCPServer.OnExecute event?

Previous  Top  Next

Since the server triggers the OnExecute event in the context of a server connection thread, you need to maintain an individual TSession for each thread. However, you need to select a database driver which is thread-safe meaning it can be used for concurrent access in several threads. Some database drivers may not be thread safe so please ask the database engine vendor about this before using it.

 

If you are using third-party BDE replacements, you need to consult your documentation or ask the vendor if their product is thread-safe and follow their instructions for using the component in multi-threaded servers.