Recent

Author Topic: New to web programming, some questions about DB connections  (Read 3287 times)

gerardus

  • Jr. Member
  • **
  • Posts: 92
New to web programming, some questions about DB connections
« on: December 05, 2016, 01:23:34 pm »
Hi,

I started playing with Lazarus & the Brook framework to make a standalone web ser app.
I need this server application to access a Firebird database.
http://silvioprog.github.io/brookframework/
Is the auto-generated server application multithreaded?  If so, do I need some kind of locking to use SQLDB components?

best regards,

Gerard.

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: New to web programming, some questions about DB connections
« Reply #1 on: December 05, 2016, 01:38:22 pm »
Connection to database is in most case single threaded therefore you might need a connection for each thread or a critical section (slower).
As far as I can recall the embedded Brook web server can work multi threaded.
Lazarus 2.0.2 64b on Debian LXDE 10

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: New to web programming, some questions about DB connections
« Reply #2 on: December 06, 2016, 12:04:23 pm »
Is the auto-generated server application multithreaded?
No, but can be activated in a single line:
Code: Pascal  [Select][+][-]
  1. (BrookApp.Instance as TBrookHTTPApplication).Threaded := true;
  2.  
If so, do I need some kind of locking to use SQLDB components?
I don't need it when using MariaDB, but perhaps other dbms requires it.

gerardus

  • Jr. Member
  • **
  • Posts: 92
Re: New to web programming, some questions about DB connections
« Reply #3 on: December 06, 2016, 12:19:05 pm »
Thanks for your replies.

hrayon

  • Full Member
  • ***
  • Posts: 118
Re: New to web programming, some questions about DB connections
« Reply #4 on: December 06, 2016, 01:00:24 pm »
Are you using the embedded version(Firebird 2.5.0 or greater)?
The embedded libraries - libfbembed.so on POSIX and fbembed.dll on Windows - are now multi-thread-capable and thread-safe, so they can be used in multi-threaded applications.

gerardus

  • Jr. Member
  • **
  • Posts: 92
Re: New to web programming, some questions about DB connections
« Reply #5 on: December 06, 2016, 01:17:03 pm »
I am using the linux client library against a windows server.
If the project finally is done, I won't be able to use the embedded libs.
It will be against a server that is already in production in a classic client/server setup.
Thanks for pointing this, it seems that all the client libs are thread-safe from 2.5 on?
http://firebirdsql.org/file/documentation/release_notes/html/en/2_5/rnfb25-engine-thrdsafe.html
« Last Edit: December 06, 2016, 01:18:57 pm by gerardus »

 

TinyPortal © 2005-2018