RDC - How to trap & display SQL errors

Frank Cazabon

Member
Licensed User
Longtime User
Hi,

I've been using the RDC tool with great success. My one problem is how to trap and display the error message that gets displayed on the server when there is a problem with the SQL command being run.

Currently I have:

B4X:
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
        Msgbox("Error: " & Job.ErrorMessage, "Unable to query Remote Database")
       
    Else

But when there is an SQL problem I just get "Server Error" as Job.ErrorMessage.

Is there another property that I can use to display the SQL error?
 

Frank Cazabon

Member
Licensed User
Longtime User
Thanks, but I'm not understanding that thread fully. It looks like it is saying I can change the httputils2 library to do what you say (I guess this library is used by the RDC library?) I downloaded the httputils2 zip file, but I can't open it in B4A, it looks like there is a b4j file there. Is there a b4a version somewhere?
 
Upvote 0

alienhunter

Active Member
Licensed User
Longtime User
Thanks, but I'm not understanding that thread fully. It looks like it is saying I can change the httputils2 library to do what you say (I guess this library is used by the RDC library?) I downloaded the httputils2 zip file, but I can't open it in B4A, it looks like there is a b4j file there. Is there a b4a version somewhere?


see here
https://www.b4x.com/android/forum/t...-services-are-now-even-simpler.18992/#content



Change HttpUtils2Service
that is how i catch those errors

B4X:
Sub Process_Globals
   Private hc As HttpClient
   Private TaskIdToJob As Map
   Public TempFolder As String
   Private taskCounter As Int
   Private Responsx As String
End Sub



Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
   If Response <> Null Then
     Try
       'Log(Response.GetString("UTF8"))
       Responsx=Response.GetString("UTF8")
     Catch
       'Log("Failed to read error message.")
       Responsx="Failed to read error message."
     End Try
     Response.Release
   End If
   CompleteJob(TaskId, False, Reason)



Sub CompleteJob(TaskId As Int, success As Boolean, errorMessage As String)
   Dim job As HttpJob
   job = TaskIdToJob.Get(TaskId)
   TaskIdToJob.Remove(TaskId)
   job.success = success
   job.errorMessage = Responsx
   job.Complete(TaskId)
End Sub


End Sub
 
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
Thanks, but I'm still not following how httputils2 is related to the RDC. Are you telling me that RDC uses httputils2 to communicate and that I should replace my existing httputils with a new one?
 
Upvote 0

alienhunter

Active Member
Licensed User
Longtime User
Thanks, but I'm still not following how httputils2 is related to the RDC. Are you telling me that RDC uses httputils2 to communicate and that I should replace my existing httputils with a new one?

ohhh sh... i forgot this sorry
yes you have to use this , make sure you do not have the HttpUtils2 library checked in case you used this before



upload_2015-3-27_15-50-59.png



you know you have to import the 2 files from the link and change them right ?
add existing modules
moudel.jpg
 
Last edited:
Upvote 0

rad

Member
Licensed User
Longtime User
Hi alienhuter...

I have the same issue Frank...
I have implement RDC in my project successfully... but the issue is, all error from mysql (like unique constraint, duplicate entry), in my application only displaying "Server Error". Not displaying error message from MySQL specifically.

Please help me to solve this issue...

This What i have...

B4X:
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
        Msgbox (Job.ErrorMessage, "Job Error")
        ProgressDialogHide
    Else
        If Job.JobName = "DBRequest" Then
            Dim result As DBResult = reqManager.HandleJob(Job)
           
            Select result.Tag
                Case "LoadData"
                    'Tampilkan data ke dalam bentuk Table.
                    tblData.LoadRDCResult(result, True)
                   
                    'Set alignment for each cell
                    Dim alignments() As Int
                    alignments = Array As Int (Bit.Or(Gravity.CENTER, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL),  Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL),  Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL),  Bit.Or(Gravity.CENTER, Gravity.CENTER_VERTICAL),  Bit.Or(Gravity.CENTER, Gravity.CENTER_VERTICAL),  Bit.Or(Gravity.CENTER, Gravity.CENTER_VERTICAL))
                    tblData.SetCellAlignments(alignments)
                    '---------------------------
                                       
                    ProgressDialogHide
                   
                    If result.Rows.Size = 0 Then
                        ToastMessageShow("Data is empty...", True)
                    Else               
                        ToastMessageShow("Long Touch selected row to see detail advertising...", True)
                        tblData.JumpToRowAndSelect(0,0)
                    End If
 
Upvote 0
Top