Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you guys code your database connection
#6
(05-16-2018, 10:21 AM)morhous Wrote: What i trying to do is make connection in servercontroller for connect only when server starts. So far i did it in my forms, actually it was bad every time page render it connects over and over. So i am asking how you guys make connection only 1 time when server starts

Although you are allowed to connect to anything from ServerController you must have in mind that no form of connection present in your ServerController should be shared among user sessions. Meaning: Do not connect DataSets in other places to that ServerController. The ServerController is a singleton, used (shared) by all your sessions, running in different threads.
So, your ServerController connection should be only used to, for instance, retrieve global options for your application, from the database, or saving an application log (in a thread-safe way, of course).

The best way to do it: Add a TSomeDBConnection to your UserSession and connect if from there. Each user session has a dedicated connection to the Database.
Reply


Messages In This Thread
RE: How do you guys code your database connection - by Alexandre Machado - 05-17-2018, 09:41 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)