Several months ago I wrote and tested the code below with MariaDB 5 and mariadb-java-client-2.3.0. I am sure it was working.
Today I am using MariaDB10 and mariadb-java-client-2.4.4 and I am seeing nullpointerexceptions.
Here's what I know. The following code calls the routine that is giving me the problem:
The code where the error is thrown is n this sub:
If I don't try to create a batch and instead use this direct instruction :
it works without errors (but there are reasons I want to batch it, and I have other places where I use similar code.).
The error log is as follows (removed the Try/Catch loop to give multiple lines of the log):
So essentially - my code refuses to create the batch.
Am I doing something wrong here, or is there something else going on?
Today I am using MariaDB10 and mariadb-java-client-2.4.4 and I am seeing nullpointerexceptions.
Here's what I know. The following code calls the routine that is giving me the problem:
B4X:
' Connect to the MusicBase
dtmm_SQL.CP.GetConnectionAsync("sqlMB")
wait for sqlMB_ConnectionReady(Connected As Boolean, sqlMB As SQL)
If Connected Then
' Queue the Addrecording command
Wait for (dtmm_SQL.Add_TableRecord(sqlMB, dtmm_SQL.cmdAddRecording, lstArgs, False)) Complete (Success As Boolean)
' Queue the AddExtRecording and execute both commands
Wait for (dtmm_SQL.Add_TableRecord(sqlMB, dtmm_SQL.cmdAddExtRecording, lstExtArgs, True)) Complete (Success As Boolean)
CDAdded = Success
End If
sqlMB.Close
B4X:
Public Sub Add_TableRecord(sqlMB As JdbcSQL, Query As String, lstArgs As List, LastInBatch As Boolean) As ResumableSub
Log("Sub: Add_TableRecord")
Dim RecordsAdded As Boolean
Try
' This line throws an error
sqlMB.AddNonQueryToBatch(Query, lstArgs)
If LastInBatch Then
' Run the batch asynchronously
Wait For (sqlMB.ExecNonQueryBatch("sqlMB")) sqlMB_NonQueryComplete (Success As Boolean)
RecordsAdded = Success
End If
' Works
' sqlMB.ExecNonQuery2(Query, lstArgs)
Catch
dtmm.Log_Error(LastException.Message)
End Try
Return RecordsAdded
End Sub
B4X:
sqlMB.ExecNonQuery2(Query, lstArgs)
The error log is as follows (removed the Try/Catch loop to give multiple lines of the log):
B4X:
Error occurred on line: 455 (dtmm_SQL)
java.lang.NullPointerException
at anywheresoftware.b4j.objects.SQL.AddNonQueryToBatch(SQL.java:224)
at b4j.DestopMusicMachine.dtmm_sql$ResumableSub_Add_TableRecord.resume(dtmm_sql.java:1203)
at b4j.DestopMusicMachine.dtmm_sql._add_tablerecord(dtmm_sql.java:1164)
at b4j.DestopMusicMachine.claddcd$ResumableSub_btnAddClose_Click.resume(claddcd.java:342)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:136)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:85)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$3.run(BA.java:247)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:201)
at javafx.graphics/com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:509)
at javafx.graphics/com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:591)
at javafx.graphics/javafx.stage.Stage.showAndWait(Stage.java:465)
at anywheresoftware.b4j.objects.Form.ShowAndWait(Form.java:215)
at b4j.DestopMusicMachine.claddcd$ResumableSub_ShowMe.resume(claddcd.java:166)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
So essentially - my code refuses to create the batch.
Am I doing something wrong here, or is there something else going on?