多线程的数据库程序中,每个线程要是使用自己的数据库连接。
给你的每个线程创建不同的SESSION试试。
可以参考DELPHI中的Session component的相关帮助:You can create sessions to supplement the default session. At design time, you can place additional sessions on a data module (or form), set their properties in the Object Inspector, write event handlers for them, and write code that calls their methods. You can also create sessions, set their properties, and call their methods at runtime. This section describes how to create and delete sessions at runtime.Note: Keep in mind that creating additional sessions is optional unless an application runs concurrent queries against a database or the application is multi-threaded.To enable dynamic creation of a session component at runtime, follow these steps:1 Declare a pointer to a TSession variable.
2 Instantiate a new session by calling the Create constructor. The constructor sets up an empty list of database components for the session, sets up an empty list of BDE callbacks for the session, sets the KeepConnections property to True, and adds the session to the list of sessions maintained by the application抯 session list component.
3 Set the SessionName property for the new session to a unique name. This property is used to associate database components with the session. For more information about the SessionName property, see Naming a session.4 Activate the session and optionally adjust its properties.Note: Never delete the default session.You can also manage creating and opening of sessions using the OpenSession method of TSessionList. Using OpenSession is safer than calling Create, because OpenSession only creates a session if it does not already exist. For more information about using OpenSession, see Managing multiple sessions..