Studio web server connecting to multiple databases simultaneously

Bruno Del Sol bruno.delsol at bydesign.fr
Sun Nov 8 13:40:07 EST 2020


   Hi Mayada,

   All my Omnis 10 js apps do this, I call it lazy connect. The actual
   database connection is done only when the first SQL statement is to be
   sent to the server. It runs ok with MySQL and PGSQL and should run ok
   also with MSSQLServer.

   The actual code is as below :

   $some_task_method
   ---------------------------

   Begin statement
   Sta: select blabla ...
   End statement
   Do method $ctask.$SQLexec Returns F

   $SQLexec
   --------------

   Do method checkSqlSession Returns F

   If isclear(F)

   Quit method 0

   End If

   Calculate ErrorCode as 0

   Calculate ErrorText as ''

   Do SQLSession.$clear()

   Do SQLBuffer.$execdirect(statement) Returns F

   Get statement SQLText

   If F=1

   Quit method 1

   End If

   Calculate ErrorCode as
   abs(pick(SQLBuffer.$nativeerrorcode=0,SQLBuffer.$nativeerrorcode,SQLBuf
   fer.$errorcode))

   Calculate ErrorText as
   abs(pick(SQLBuffer.$nativeerrortext=0,SQLBuffer.$nativeerrortext,SQLBuf
   fer.$errortext))

   Signal error 100000+ErrorCode,ErrorText

   Quit method 0

   CheckSqlSession
   -------------------------

   If isnull(SQLSession)

   Do method $SQLconnect Returns message

   Quit method len(message)=0

   End If

   If len(SQLSession.$class().$name)=0

   Do method $SQLconnect Returns message

   Quit method len(message)=0

   End If

   If Dam='PGSQL'

   If SQLSession.$connectstatus<>kPgSqlConnectionOK

   Do method $SQLconnect Returns message

   Quit method len(message)=0

   End If

   End If

   If Dam='MYSQL'

   If isclear(SQLSession.$ping)

   Do method $SQLconnect Returns message

   Quit method len(message)=0

   End If

   End If

   Quit method 1

   $SQLconnect
   ------------------

   ## clears up SQLSession ans SQLBuffer
   ## set up SQLSession ans SQLBuffer
   ## do $logon

   ## returns message if failed

   HTH
   Regards
   Bruno

By Design
[1]http://www.bydesign.fr
Bruno Del Sol
[2]bruno.delsol at bydesign.fr
46, rue de La Tour d'Auvergne
75009 Paris (France)

   Le 08/11/2020 à 18:53, [3]malkishtini at gmail.com a écrit :

 Good day $all,

Has anyone design a web app in Studio where the connection to the database is es
tablished in the remote task when the client issues a call to the JS client and
passes the connection string to the remote task?
I.e. I'm wondering if Omnis web server can handle connections to multiple databa
ses at the same time using a "single instance" of the server!
So I'm thinking that the server starts without any database connection, then the
 connection to the database gets established in the remote task when the user ca
lls a JS client.
I have not seen such a case in an Omnis web app before, that's why I thought to
post the question to the list and see if this has been done before and how that
might affect the server performance.

Thank you,
Mayada

_____________________________________________________________
Manage your list subscriptions at [4]http://lists.omnis-dev.com
Start a new message -> [5]mailto:omnisdev-en at lists.omnis-dev.com

References

   1. http://www.bydesign.fr/
   2. mailto:bruno.delsol at bydesign.fr
   3. mailto:malkishtini at gmail.com
   4. http://lists.omnis-dev.com/
   5. mailto:omnisdev-en at lists.omnis-dev.com


More information about the omnisdev-en mailing list