### Get SQLite version

Example Non-UI application application to get the SQLite version.
Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
'SQLite driver located in the B4J Core Libraries folder
#AdditionalJar: sqlite-jdbc-3.7.2
End Region
`Sub Process_Globals
Private sqlObj As SQL 'uses the jSQL Library
Private sqlDBFile As String 'the sqllite database stored in the dirapp folder
End Sub`
`Sub AppStart (Args() As String)
Try
sqlDBFile = "test.db"
'Open the sqlite database located in the same folder as the Jar by using the SQLite Helper class InitializeSQLite.
'Note that the flag CreateIfNecessary is set to true
sqlObj.InitializeSQLite(File.DirApp, sqlDBFile, True)
'Get the sqlite version
Log($"SQLite Version ${GetSqliteVersion(sqlObj)}"$)
'SQLite Version 3.7.2
'Get the sqlite version
Log($"SQLite Version ${GetSQLiteVersion2}"$)
Catch
Log($"Init SQLite Error ${LastException.Message}"$)
End Try
StartMessageLoop
ExitApplication
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`
'Get SQLite Version with sqlite object as parameter
'Example`GetSqliteVersion(sqlObj)`
`Sub GetSqliteVersion(sqlDB As SQL) As String
Dim result As String
Try
result = sqlDB.ExecQuerySingleResult("SELECT sqlite_version();")
Catch
result = LastException
End Try
Return result
End Sub`
'Get SQLite Version with sqlite object defined as global
'Example`GetSqliteVersion(sqlObj)`
`Sub GetSQLiteVersion2 As String
Dim result As String
Dim cursor As ResultSet
Dim cmd As String = "SELECT sqlite_version();"
Try
cursor = sqlObj.ExecQuery (cmd)
Do While cursor.NextRow
result = cursor.GetString2(0)
Loop
Catch
Log("ERROR: " & LastException.Message)
End Try
Return result
End Sub`

Changed: , Category: SQLite, File: T6C254M1827.htm, ID: 1827