Hi everyone.
I developed an application that accesses MySql remotely.
The provider (Hostgator) sent me an alert saying that I am sending too many requests to the database.
The log of requests they sent me does not help much:
I'm guessing that may be the way I'm accessing the database.
Is everything correct with my code?
I developed an application that accesses MySql remotely.
The provider (Hostgator) sent me an alert saying that I am sending too many requests to the database.
The log of requests they sent me does not help much:
Running Queries:
1. row
USER: appfoodc_admin
DB: appfoodc_byappfood
STATE:
TIME: 22
COMMAND: Sleep
INFO:
2. row
USER: appfoodc_admin
DB: appfoodc_byappfood
STATE:
TIME: 87
COMMAND: Sleep
INFO:
...
I'm guessing that may be the way I'm accessing the database.
Is everything correct with my code?
B4X:
Sub Process_Globals
Dim pool As ConnectionPool, Hostgator As SQL
end sub
Sub AppStart (Form1 As Form, Args() As String)
server = "jdbc:mysql://mydomain.com.br/myfolder"
Try
pool.Initialize("com.mysql.cj.jdbc.Driver", server, "user", "password")
Catch
log("Connection error")
ExitApplication
End Try
end sub
Sub Write(query As String) As Boolean
Try
Hostgator = pool.GetConnection
Hostgator.BeginTransaction
Hostgator.ExecNonQuery(query)
Hostgator.TransactionSuccessful
Hostgator.Close
Return True
Catch
Log(LastException)
'''''''''''''''''''''''''
' hostgator.close here? '
'''''''''''''''''''''''''
Return False
End Try
End Sub
Sub Read(q As String) As Object
Try
Hostgator = pool.GetConnection
Dim tmp As Object
tmp = Hostgator.ExecQuerySingleResult(q)
Hostgator.Close
Catch
Log(LastException)
'''''''''''''''''''''''''
' hostgator.close here? '
'''''''''''''''''''''''''
Return Null
End Try
Return tmp
End Sub