Sub OpenMySQL(serverIP As String, serverPort As String, serverDB As String, login As String, password As String) As Boolean
'Log("init mysql")
UsePool = True
If IsOpen Then
SQLite = pool.GetConnection
Return True
End If
Try
Dim jdbcUrl As String = $"jdbc:mysql://${serverIP}:${serverPort}/${serverDB}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowLoadLocalInfile=True"$
pool.Initialize("com.mysql.cj.jdbc.Driver", jdbcUrl, login, password)
Dim jocp As JavaObject = pool
jocp.RunMethod("setMaximumPoolSize", Array(PoolSize))
jocp.RunMethod("addDataSourceProperty", Array("cachePrepStmts", True))
jocp.RunMethod("addDataSourceProperty", Array("prepStmtCacheSize", 250))
jocp.RunMethod("addDataSourceProperty", Array("prepStmtCacheSqlLimit", 2048))
jocp.RunMethod("addDataSourceProperty", Array("useServerPrepStmts", True))
jocp.RunMethod("addDataSourceProperty", Array("useLocalSessionState", True))
jocp.RunMethod("addDataSourceProperty", Array("useLocalTransactionState", True))
jocp.RunMethod("addDataSourceProperty", Array("rewriteBatchedStatements", True))
jocp.RunMethod("addDataSourceProperty", Array("cacheResultSetMetadata", True))
jocp.RunMethod("addDataSourceProperty", Array("cacheServerConfiguration", True))
jocp.RunMethod("addDataSourceProperty", Array("elideSetAutoCommits", True))
jocp.RunMethod("addDataSourceProperty", Array("maintainTimeStats", True))
Dim thres As Long = 60000
jocp.RunMethod("setLeakDetectionThreshold", Array(thres))
SQLite = pool.GetConnection
IsOpen = True
Return True
Catch
IsOpen = False
Log("OpenMySQL: " & LastException.Message)
Return False
End Try
End Sub