Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where should i set my database connection
should set connection server controller or , user session
In the UserSession, if you are providing data for the pages of your application. Each client gets a copy of the UserSession. The ServerController is created once when your application is started. You can also access data there, but that is not a good place to get data for the sessions unless you have a specialized case that requires it.
(07-05-2018, 02:24 AM)morhous Wrote: should set connection server controller or , user session

Just complementing Dan's answer:
as a rule of thumb, nothing which is shared should ever be put in ServerController. Not even if you have some internal critical section to avoid concurrent access to that resource. 
If multiple sessions need access to some type of resource (file, Database, network, e-mail server, whatever), this should be put in UserSession, or - my preferred solution - create a class which does what needs to be done, instantiate it when needed, do what needs to be done and then release it. Of course, this solution doesn't apply to Database connections.
Maybe the 'correct' solution can be the SUM of the above recomendations.
It is prefered not to use Shared Stuff. Not because IW Can't handle it, It does, but if you dont have spcecial care, it can let your cod to lock or slow down the application performance.

Let each Session has its own instances and release them. So Create a Class that will use that stuff and instantiate it in the UserSession datamodule. It could be another datamodule, for example a datamodule that contains your connection and datasets, with this you keep the UserSession Object cleaner and only add methods to instantiate and release your custom classes.

Forum Jump:

Users browsing this thread: 1 Guest(s)