#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
#Region Database Location
' do not worry: created just for test
Private DBUsername As String = "us13022020"
Private DBPassword As String = "12345678"
Private DriverClass As String = "com.mysql.jdbc.Driver"
Private JdbcURL As String = "jdbc:mysql://db4free.net/db13022020?characterEncoding=utf8"
Private pool As ConnectionPool, db As SQL
Private sp As Form
#End Region
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
ShowWait ' transparent form wiht a wait animated gif
' Its not showing up
PreparingSystem ' initial database stuff
' should stay visible until PreparingSystem finishs
sp.Close ' closes the wait form
MainForm.Show
fx.Msgbox(MainForm, "SYSTEM READY!", "")
End Sub
Sub ShowWait
sp.Initialize("sp", 300, 300)
sp.WindowLeft = 0
sp.WindowTop = 0
sp.SetFormStyle("TRANSPARENT")
sp.BackColor = fx.Colors.Transparent
'change image here
CSSUtils.SetBackgroundImage(sp.RootPane, File.DirAssets, "wait.gif")
sp.Show
End Sub
Sub PreparingSystem
Log("Preparing system...")
Try
Log("Connecting...")
pool.Initialize(DriverClass, JdbcURL, DBUsername, DBPassword)
Catch
fx.Msgbox(MainForm, LastException, "Connection error")
ExitApplication
End Try
db = pool.GetConnection
db.BeginTransaction
For i = 1 To 2
Log("R/W " & i)
Dim nrec As Int = db.ExecQuerySingleResult("SELECT count(*)+1 FROM table1")
Log(db.ExecQuerySingleResult("SELECT text FROM table1 WHERE id = " & Rnd(1, nrec)))
db.ExecNonQuery($"INSERT INTO table1 (text) values (${DateTime.Now})"$)
Next
db.TransactionSuccessful
db.Close
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
Return True
End Sub