#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar: mssql-jdbc-7.4.1.jre8.jar
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private DBDriver As String = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
Private DBLocation As String = "jdbc:sqlserver://DomainName||IPAddress:PortNumber[/OptionalDBName][;Optional1stParameter][;Optional2ndParamter][;OptionalNthParameter]"
'Note: the above could be as simple as
'"jdbc:sqlserver://127.0.0.1:1433"
'or even something like this
'"jdbc:sqlserver://subdomain.acme.com:1000/secretdb;sslProtocol=TLS;trustServerCertificate=true"
Private DBUsername As String = "DBUsername"
Private DBPassword As String = "DBPassword"
Private Conn As SQL
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
Conn.InitializeAsync("conn1",DBDriver,DBLocation,DBUsername,DBPassword)
Wait For conn1_Ready(Success As Boolean)
If Not(Success) Then
Log("Failed to connect to database. Bye!")
ExitApplication
End If
Log("Successfully connected!")
Wait For (Conn.ExecQueryAsync("sql","SELECT * FROM SYS.TABLES", Null)) sql_QueryComplete(Success As Boolean, rs As ResultSet)
If (Success) Then
Do While rs.NextRow
Log(rs.GetString2(0))
Loop
rs.Close 'Do not forget to close your result set!
Else
Log("Query was not successful!")
End If
Conn.Close 'Closing the DB connection
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