B4J Question jSQL 1.51 NullPointerException Issue

Mashiane

Expert
Licensed User
Longtime User
Kinda confused...

B4X:
Public Sub ExecuteMap(jSQL As SQL, Query As String, StringArgs() As String) As Map
    Dim res As Map
    Dim cur As ResultSet
    If StringArgs <> Null Then
        cur = jSQL.ExecQuery2(Query, StringArgs)
    Else
        cur = jSQL.ExecQuery(Query)
    End If
    If cur.NextRow = False Then
        'Log("No records found.")
        Return res
    End If
    res.Initialize
    For i = 0 To cur.ColumnCount - 1
        Dim fName As String = cur.GetColumnName(i)
        Dim fValue As String = cur.GetString2(i)
        Log(GetType(fValue))
        Log(fName)
        Log(fValue)
        'If fValue = "null" Then fValue = ""
        res.Put(cur.GetColumnName(i).ToLowerCase, fValue)
    Next
    cur.Close
    Return res
End Sub

A funny thing here, some records in my database table return the field names properly and the column values and some just return NullPointerException at the Log(GetType(fValue)) line. If I comment out the

B4X:
If fValue = "null" then fValue = ""
, it also just crashes on that line. An intergrity check

PRAGMA integrity_check

returns ok. What could I be doing wrong?

I want the map that is returned not to have null values as those need to be just blank.
 

Mashiane

Expert
Licensed User
Longtime User
B4X:
Upgrade
1
java.lang.String
Defaults
java.lang.String
id
1
java.lang.String
id
1
java.lang.String
AppName
Contacts1
java.lang.String
InitialPage
addeditcontact/addeditcontact.html
java.lang.String
AppPublishedStartURL
null
java.lang.String
ThemeName
Error occurred on line: 954 (DBUtils)
java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.Common.GetType(Common.java:369)
    at b4j.Mashy.PenNPaper.dbutils._executemap(dbutils.java:2453)
    at b4j.Mashy.PenNPaper.dbutils._readrecord(dbutils.java:838)
    at b4j.Mashy.PenNPaper.dbutils._addeditrecord(dbutils.java:80)
    at b4j.Mashy.PenNPaper.modabmaterial._updateappdatabase(modabmaterial.java)
    at b4j.Mashy.PenNPaper.modabmaterial._preparedatabase(modabmaterial.java:18222)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at anywheresoftware.b4a.BA$1.run(BA.java:215)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    at java.lang.Thread.run(Thread.java:748)
 
Upvote 0
Top