hello everyone !!
I have the following problem, when I initialize a Jserver, I initialize the DB class and check if there is a connection, calling a DB.Sync to ensure that the bank has been connected ... but I noticed that every time I check the amount of Polls open, always starts with 3 polls being that I only made 1 query , is this normal?
Codes :
[ Main ]
[DB Class]
Screenshot :
I have the following problem, when I initialize a Jserver, I initialize the DB class and check if there is a connection, calling a DB.Sync to ensure that the bank has been connected ... but I noticed that every time I check the amount of Polls open, always starts with 3 polls being that I only made 1 query , is this normal?
Codes :
[ Main ]
B4X:
Sub Process_Globals
Public srvr As Server
End Sub
Sub AppStart (Args() As String)
srvr.Initialize("srvr")
srvr.Port = 51042
srvr.AddHandler("/teste", "testes", False)
DB.Initialize
DB.Sync 'Here init query - Show Tables;
ServerManager.Initialize
srvr.Start
Log("Server Running on Port [51042].")
StartMessageLoop
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Log("Error = "&Error)
Log("StackTrace = "&StackTrace)
Return True
End Sub
[DB Class]
B4X:
Sub Process_Globals
Public pool As ConnectionPool
Dim jo As JavaObject
End Sub
Public Sub Initialize
pool.Initialize("com.mysql.jdbc.Driver","jdbc:mysql://127.0.0.1:3306/testdb?characterEncoding=utf8&autoReconnect=true&useSSL=false","root","")
jo = pool
jo.RunMethod("setMinPoolSize", Array(0))
jo.RunMethod("setMaxPoolSize", Array(50))
jo.RunMethod("setMaxIdleTime", Array As Object(60))
jo.RunMethod("setMaxStatements", Array As Object(1))
jo.RunMethod("setNumHelperThreads", Array As Object(10))
jo.RunMethod("setCheckoutTimeout", Array As Object(60000))
jo.RunMethod("setMaxIdleTimeExcessConnections", Array As Object(60))
End Sub
Public Sub LogPoolStatus
If pool.IsInitialized Then Log("CurrentPoolConnections = " & jo.RunMethod("getNumConnections",Null) & " | MaxPoolConnections = " & jo.RunMethod("getMaxPoolSize",Null))
End Sub
Public Sub Sync
LogPoolStatus
Dim sql1 As SQL = pool.GetConnection
Dim rs As ResultSet = sql1.ExecQuery("Show tables")
If rs.NextRow Then
Log("Database Sync")
Else
ExitApplication
End If
rs.Close
sql1.Close
LogPoolStatus
End Sub
Screenshot :