Jump to content

Database connection


LogSistemas01

Recommended Posts

Hello people,

I'm starting at Unigui and doing VCL conversion. My team and I have the following scenario regarding connection to the database.

We have a class that manages the connection to the database. Every time it is needed, it is created and connected to the database, and after completing the process it is destroyed. This way, at various times, the application will not be connected to the bank.

In the other case, it would be to have the connection component in the MainModule connected all the time.

I would like to know what you think would be better in terms of consuming less resources, since one option stays connected all the time and the other makes several connections?
If anyone has or has had this scenario and can give some feedback, I would be grateful.

Any tip is welcome.
Thank you!

Link to comment
Share on other sites

Transform you system to work with rest server.. uses DataSnap or RestDataware.

Each procedures/functions will create a connection in runtime, execute, and return a json.

In UniGUI project, create process to call this rest server e process this json.

In future, you architecture will works with any type of client side and will consume lowerest resource.

Link to comment
Share on other sites

This advice is if you are using FireDAC but should be possible with other libs.

To keep minimum database connections  at any one time, use "offlining connection" option of FireDAC combined with "connection pooling".

This way you open the connection when you require and do your job and put it back to offline mode.

These links has the information

http://docwiki.embarcadero.com/RADStudio/Rio/en/Offlining_Connection_(FireDAC)

http://docwiki.embarcadero.com/RADStudio/Rio/en/Multithreading_(FireDAC)     (Connection Pooling)

Also check uniGUI docs for proper use of FireDAC components in multi threaded apps.

 

Link to comment
Share on other sites

52 minutes ago, NelZ said:

Transform you system to work with rest server.. uses DataSnap or RestDataware.

Each procedures/functions will create a connection in runtime, execute, and return a json.

In UniGUI project, create process to call this rest server e process this json.

In future, you architecture will works with any type of client side and will consume lowerest resource.

Yes, we are studying restdataware.
But until we learn, we are in that situation.

But thanks for the advice.

But what did you say, does restdataware automatically create and destroy the connection?

Thank you again!

Link to comment
Share on other sites

40 minutes ago, Mehmet Emin said:

This advice is if you are using FireDAC but should be possible with other libs.

To keep minimum database connections  at any one time, use "offlining connection" option of FireDAC combined with "connection pooling".

This way you open the connection when you require and do your job and put it back to offline mode.

These links has the information

http://docwiki.embarcadero.com/RADStudio/Rio/en/Offlining_Connection_(FireDAC)

http://docwiki.embarcadero.com/RADStudio/Rio/en/Multithreading_(FireDAC)     (Connection Pooling)

Also check uniGUI docs for proper use of FireDAC components in multi threaded apps.

 

Nice! Thank you!! I didnt know about "offlining connection".

Link to comment
Share on other sites

20 minutes ago, LogSistemas01 said:

Yes, we are studying restdataware.
But until we learn, we are in that situation.

But thanks for the advice.

But what did you say, does restdataware automatically create and destroy the connection?

Thank you again!

Inside RestDataware, you can create a method and publish it, creating a connection object variable (like firedac / zeos), process it and finally destroy it.
Or, you can use the one automatically configured by RESTDWDataBase. TServerMethodDataModule is always created automatically and destroyed.
As for using Firedac with cache, be careful when synchronizing when the connection returns.
Because another user can change the data that was cached on another computer, there you have to work with concurrency errors, in addition to the risk of losing launches due to the permanent loss of connection. In this case, the user complains that he made many postings and lost the records.
This cache option is great if the user continues to include / change / exclude and maintain search data, but when he returns online, you have to deal with problems that may appear.
Attention, the server should not keep too much in cache, otherwise you will have a lot of problems with high memory consumption and risk of deadlock in the tables.
In my opinion, the best thing is to keep the memory on the server side to a minimum. Because when the server goes down, or returns, everything continues.
If you had caches, there are problems with restoring the point you were on.
And that is what the REST way of working has the advantage.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...