B4J Question java.lang.NumberFormatException: For input string: "null" Why is there an error when data can be found in the database? Thank you

guandjy

Member
java.lang.NumberFormatException: For input string: "null":
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Tag: null, Columns: 3, Rows: 1
BUMEN    FEIYONGGUIJI    jine 
danggong    richang    308290.0 
zhujiemian$ResumableSub_zhichuchaxun.resume (java line: 696)
java.lang.NumberFormatException: For input string: "null"
    at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
    at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.base/java.lang.Double.parseDouble(Double.java:549)
    at anywheresoftware.b4a.BA.ObjectToNumber(BA.java:434)
    at b4j.example.zhujiemian$ResumableSub_zhichuchaxun.resume(zhujiemian.java:696)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:513)
    at anywheresoftware.b4a.keywords.Common.access$0(Common.java:493)
    at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:567)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    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._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:832)

code:
Dim req As DBRequestManager = CreateRequest

 Dim cmd As DBCommand = CreateCommand("select_tubiao", Array("danggong"))

 

    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)

    If j.Success Then

        req.HandleJobAsync(j, "req")

        Wait For (req) req_Result(res As DBResult)

        req.PrintTable(res)

        Dim data As List

        data.Initialize

        For Each row() As Object In res.Rows

            Dim val1 As String = row(res.Columns.Get("bumen"))

            Dim val2 As String = row(res.Columns.Get("feiyongguiji"))

            Dim val3 As Double = row(res.Columns.Get("jine"))

          

            data.Add(Array(val1,val2,val3))

          

        Next

        B4XTable1.AddColumn("lie1",B4XTable1.COLUMN_TYPE_TEXT)

        B4XTable1.AddColumn("lie2",B4XTable1.COLUMN_TYPE_TEXT)

        B4XTable1.AddColumn("lie3",B4XTable1.COLUMN_TYPE_NUMBERS)

      

  

        B4XTable1.SetData(data)

        B4XTable1.Refresh

        'B4XTable1.NumberOfFrozenColumns= 1

    Else

        Log("ERROR: " & j.ErrorMessage)

    End If

    j.Release
 

guandjy

Member
B4X:
Dim val1 As String = row(res.Columns.Get("BUMEN")) 'case is important in Map keys
Dim val2 As String = row(res.Columns.Get("FEIYONGGUIJI"))
Dim val3 As Double = row(res.Columns.Get("jine"))
SELECT bumen , feiyongguiji, sum(...) AS jine
FROM zhichuchaxun
GROUP BY bumen, feiyongguiji;

Change the above code to:

SELECT bumen as bumen, feiyongguiji as feiyongguiji, sum(...) AS jine
FROM zhichuchaxun
GROUP BY bumen, feiyongguiji;

Okay, that's it, my powerful deity ,thank you
 
Upvote 0
Top