Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you guys code your database connection
#1
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
Reply
#2
Generally its better to use a datamodule/session level connection for users. ie one per session and use connection pooling. A single connection for all sessions will create a bottleneck.
Reply
#3
Yes... create your connection in the Usersession.
Reply
#4
Hi

I use the DataModule features, works well!

Eric
Reply
#5
(05-16-2018, 01:36 PM)kudzu Wrote: Generally its better to use a datamodule/session level connection for users. ie one per session and use connection pooling. A single connection for all sessions will create a bottleneck.

Sir do you have some example Code t show me.Source of Intraweb absence
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)