Android Question java.lang.RuntimeException: org.json.JSONException: End of input at character 0 of

d3vc

Member
Today i got this Error message : java.lang.RuntimeException: org.json.JSONException: End of input at character 0 of
when trying to retrieve image (blob data type )from mysql inserted by vb.net app
form my vb.net app i can retrive only the images inseted by vb.net app
and from my android app i can retrive only the once inserted by android app


B4X Code:
Buffer = su.DecodeBase64 (m.get("UserImage"))
                 InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
                Bitmap1.Initialize2(InputStream1)
                InputStream1.Close
                            
                userimg.SetBitmap(Bitmap1)
 

DonManfred

Expert
Licensed User
Longtime User
: org.json.JSONException: End of input at character 0 of
i don´t see how your code can raise this error!?

Please post the FULL ERROR as it is not related to the code you posted...
 
Upvote 0

d3vc

Member
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
(Http client initialized with accept all option.)
** Service (httputils2service) Start **

java.lang.RuntimeException: org.json.JSONException: End of input at character 0 of
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1716)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7562)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: org.json.JSONException: End of input at character 0 of
    at org.json.JSONTokener.syntaxError(JSONTokener.java:460)
    at org.json.JSONTokener.nextValue(JSONTokener.java:101)
    at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:77)
    at b4a.example.profile$ResumableSub_loaddate.resume(profile.java:641)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1714)
 
Upvote 0

d3vc

Member
i was able to retrieve the images inserted by vb.net app in my b4x app by using :
TO_BASE64() , FROM_BASE64() mysql Function .
I hope this will help who has the same issue :)

SQL:
Select To_BASE64(Image) from Tb
 
Upvote 0

d3vc

Member
For SQL Server

1-Create a Function

SQL:
create function b4xDecodeBase64 (@encoded as varchar(max))
returns varchar(max)
as
begin

    declare @decoded varchar(max)

    set @decoded = cast('' as xml).value('xs:base64Binary(sql:variable("@encoded"))', 'varbinary(max)')

    return @decoded

end

Usage :

SQL:
Select dbo.b4xDecodeBase64 (image) from Tb

Good Luck :)
 
Upvote 0
Top