In the following scenario, a remote MySQL database is accessed via ConnectionPool.
What happens to ConnectionPool when the application crashes without sending pool.ClosePool?
Can the connection get "stuck" causing a server problem?
What happens to ConnectionPool when the application crashes without sending pool.ClosePool?
Can the connection get "stuck" causing a server problem?
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar: mysql-connector-java-5.1.48.jar
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim pool As ConnectionPool
#Region Database Location
Private DBLocation As String = "999.999.999.99:3306"
Private DBname As String = "dbname"
Private DBUsername As String = "dbusername"
Private DBPassword As String = "dbpassword"
#End Region
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm.Initialize("Form", 300,300)
MainForm.Show
pool.Initialize("com.mysql.jdbc.Driver", $"jdbc:mysql://${DBLocation}/${DBname}?characterEncoding=utf8"$, DBUsername, DBPassword)
'...
End Sub
Private Sub Form_Closed()
pool.ClosePool
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
pool.ClosePool
Return True
End Sub