OutOfBoundsException when connecting to SQLDatabaseMBS

It’s now the second time I got information from a user where connecting to an SQLDatabaseMBS makes a very odd OutOfBoundsException. Session log info:

2020-11-18 12:40:13 --------------------------
2020-11-18 12:40:13 An error happened:
2020-11-18 12:40:13 Class/Method: SQLiteIndex.Write
2020-11-18 12:40:13 Time: Wednesday, 18 November 2020 12:40:13 pm Australian Eastern Standard Time 326331
2020-11-18 12:40:13 Type of Error: OutOfBoundsException
2020-11-18 12:40:13 --------------------------
2020-11-18 12:40:13 Stack:
2020-11-18 12:40:13
Function ErrorException.ParseParams(string) as string()
Function ErrorException.CleanMangledFunction(string) as string
Function ErrorException.CleanStack(RuntimeException) as string
Sub ErrorException.Constructor(RuntimeException, string)
Function SQLiteIndex.ConnectToDatabaseLocalMBS() as boolean
Sub SQLiteIndex.Write(int64, string)
Function MailParser.parse() as int64
Sub ArchiveThread.Archive()
Sub ArchiveThread.Event_Run()

call ConnectToDatabaseLocalMBS
if not ConnectedToSQLite then Return
WriteLocalMBS(theRecID, MessageBody)

exception exc
  theException = new ErrorException(exc, currentMethodName)

dim NeedToCreateIndex as Boolean

if OriginalDB = Nil then Return False
if OriginalFolderitem = nil then Return False

dim OriginalName as String = OriginalFolderitem.NameWithoutExtensionMBS
dim DBIndex as FolderItem = OriginalFolderitem.Parent.Child(OriginalName + "." + FileTypes.Index.Extensions)
if not DBIndex.Exists then NeedToCreateIndex = True

SQLiteIndexDBMBS = New SQLDatabaseMBS
SQLiteIndexDBMBS.DatabaseName = "sqlite:" + DBIndex.UnixpathMBS
SQLiteIndexDBMBS.AutoCommit = SQLDatabaseMBS.kAutoCommitOn

if SQLiteIndexDBMBS.Connect then
  ConnectedToSQLite = True
  globals.theErrorLog.LogItem CurrentMethodName + " connect"
  globals.theErrorLog.DialogErrorProceed(kErrorConnectLocal + " " + SQLiteIndexDBMBS.ErrorMessage)
  ConnectedToSQLite = False
  Return False
end if

if NeedToCreateIndex then
  ConnectedToSQLite = CreateDatabaseLocalMBS
end if

if ConnectedToSQLite then
  dim theConnection as SQLConnectionMBS = SQLiteIndexDBMBS.Connection
  dim errorMessage as string
  dim file as FolderItem = TPSF.Frameworks.Child("libicu.dylib") // an extension as FolderItem or path
  #Pragma Unused file
  if errorMessage <> "" then
    ConnectedToSQLite = False
  end if
end if

if ConnectedToSQLite then
  SQLiteIndexDBMBS.ExecuteSQL "PRAGMA cache_size = 500000" // 500 MB
  SQLiteIndexDBMBS.ExecuteSQL "PRAGMA encoding = ""UTF-8""" // encoding utf8 instead of utf16
end if

return NeedToCreateIndex

exception exc
  theException = new ErrorException(exc, currentMethodName)

There is nothing at all in the code that could make an OutOfBoundsException? Everything works in a thread. But there is only one thread with the database code.

@Christian_Schmitz: Do you have an idea what might cause the exception?

Can you output exc.stack, not theException.stack?

OutOfBoundsException is raised in [MBS Xojo SQL Plugin](https://www.monkeybreadsoftware.de/xojo/plugin-sql.shtml) when:

  • Preparedstatements have bind indexes out of range.
  • Connect and SetClient when client type is out of range.
  • ParamByIndex by index out of range
  • FieldByIndex by index out of range
  • ValueByIndex by index out of range
  • SetParametersDictionary with index out of range
  • PostgreSQL functions for field name/index with out of range of index.

And all those OutOfBoundsException have a clear message provided by the plugin.

I love to learn something new every day. The OutOfBoundsException happens in the middle of adding data. Not one reason of your list really apply here.

In your link to Monkeybread there aren’t any exceptions mentioned. The link on the page to the documentation of SQLApi is wrong, too. I’m quite sure that their email is not supprt with a missing o. And the documentation is like greek for me.

I’ll add add a couple of try/catch to see where the OutOfBoundsException comes from.

Let me fix the link. And I can add some notes to documentation.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.