Would appreciate some advice ...
In my server app I have a DB class that creates an odbc connection pool like this :
I call this init before calling srvr.Start. For each DB action, I do the following (for example) :
My app is an API server so there are many connections firing in all the time, from both users' browsers and other servers.
It all seems to work, but I wanted to know if I am doing it the "right" way. In PHP world I would make a new connection to the DB each time (sending username/password/etc.) for each user request and destroy it afterwards. But here I only "log in" to the DB server once and then use connection pooling.
Does anyone have any advice?
Thanks.
In my server app I have a DB class that creates an odbc connection pool like this :
B4X:
public Sub init
Dim JdbcUrl As String = Main.settings.Get("JdbcUrl")
Dim driverClass As String = Main.settings.Get("DriverClass")
Dim dbuser As String = Main.settings.Get("DBUser")
Dim dbpassword As String = Main.settings.Get("DBPassword")
pool.Initialize(driverClass, JdbcUrl, dbuser, dbpassword)
End Sub
I call this init before calling srvr.Start. For each DB action, I do the following (for example) :
B4X:
Public Sub MyDBAction
Dim dbcon As SQL=pool.GetConnection
....
dbcon.Close
End
My app is an API server so there are many connections firing in all the time, from both users' browsers and other servers.
It all seems to work, but I wanted to know if I am doing it the "right" way. In PHP world I would make a new connection to the DB each time (sending username/password/etc.) for each user request and destroy it afterwards. But here I only "log in" to the DB server once and then use connection pooling.
Does anyone have any advice?
Thanks.