Android Question Help needed regarding an error raised by RDC

Anser

Well-Known Member
Licensed User
Longtime User
I am using MySQL via RDC
I am calling a MySQL stored procedure which accepts 4 parameters, which does the following.

if record exists then updates the value of a column and returns a result
UPDATE Table .......
ie SELCT 0 as 'StatusID, 'Record Updated successfully' AS 'Msg'
if the record DOES NOT exist then
SELECT 1 as 'StatusID, 'ERROR Record not available' AS 'Msg'

I am getting the following Run Time error. Could not identify what is causing this error.

I am already using a similar Stored Procedure via B4A without any problem.

This is the error captured from the log. The First line is the output of the Log() which I have used inside the app

B4X:
1 2015 15070003 101
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.myapp.emptool.svrnumber
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:984)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.myapp.emptool.svrnumber
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:251)
    at java.lang.Class.forName(Class.java:216)
    at anywheresoftware.b4a.keywords.Common.getComponentBA(Common.java:1020)
    at anywheresoftware.b4a.keywords.Common.access$0(Common.java:1010)
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:929)
    ... 9 more
Caused by: java.lang.NoClassDefFoundError: com/myapp/emptool/svrnumber
    ... 15 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapp.emptool.svrnumber" on path: DexPathList[[zip file "/data/app/com.myapp.emptool-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp.emptool-2, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    ... 15 more

The code used is given below
B4X:
Sub BtnSave_Click
    If EdtSVRno.Text > 0 Then
               ' Just to recheck and ensure that the parameters and its values are correct
        Log(Main.nCompId &" "& Main.nFinYear &" "& Main.nCallRegNo &" "& EdtSVRno.Text)
          
               ' I used the following code to ensure that the data type in the text box is not a text data type
        ' The stored procedure in MySQL expects all the parameters as INT data type
        Dim nSvrNumber As Int
        nSvrNumber = EdtSVRno.Text

        Dim cmd As DBCommand
        cmd.Initialize
        cmd.Name="svr_update"
        cmd.Parameters=Array As Object(Main.nCompId,Main.nFinYear,Main.nCallRegNo,nSvrNumber)
        'ProgressDialogShow("Please wait while we update SVR details....")   
        reqManager.ExecuteQuery(cmd, 0, "SvrUpdate")

        'Tried ExecuteCommand too, but the same error
        'reqManager.ExecuteCommand(cmd,"SvrUpdate")

    Else
        Msgbox("SVR Number cannot be empty", "Invalid data")
        Return
    End If

End Sub

Sub JobDone(Job As HttpJob)
    ProgressDialogHide
    Log("Reached JobDone")
  If Job.Success = False Then
     Log("Error: " & Job.ErrorMessage)
         Msgbox("Failed : JobName = " & Job.JobName & " Unable to reach Database Server. Please ensure that you have internet connectivity on the device","Error" )
  Else
        Log("Reached JobDone JobSuccess")
     If Job.JobName = "DBRequest" Then
       Dim result As DBResult = reqManager.HandleJob(Job)

             If result.Tag = "SvrUpdate" Then 'query tag
                  reqManager.PrintTable(result)
                 VerifySvrUpdate(result)
            End If
        End If
    End If
    Job.Release
End Sub

Line from config.properties
B4X:
sql.svr_update=call SP_SVRNo_Update(?,?,?,?)

I am able to run the store procedure outside b4a ie directly from SQL without any error ie

CALL `SP_SVRNo_Update`('1', '2015', '15070003', '101')

Any hint about the error would be appreciated. Already spent more than an hour to find out what is causing this error.

One more thing to be noted is that eventhough there is error raised by RDC/B4A, the record is properly updated in MySQL.

Regards
Anser
 
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
I have multiple activities in my app. The other activities are working fine.

For each Activity, I initialize a different RDC' with different eventname on each activity. I still don't know how to use a service to handle all the RDC Queries from a single service module.

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
#Extends: android.support.v7.app.ActionBarActivity

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private ActionBar As ACToolBarLight
    Private BtnSave As ACFlatButton
    Private EdtSVRdate As ACEditText
    Private EdtSVRno As ACEditText

    Private reqManager As DBRequestManager

    Dim AC As AppCompat
    Dim ABHelper As ACActionBar    
    Private LblSvrDate As Label
    Private LblSvrNo As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("SvrNumber")

    If FirstTime Then
        reqManager.Initialize("SvrNumber", Main.RdcServerIP) ' The IP of the machine running JAVASERVER
    End If        

    'Set the ToolBar (it is called ActionBar in the layout file) as the ActionBar of this activity.
    ActionBar.SetAsActionBar

    ActionBar.Title = "Assign SVR Number"
    ActionBar.SubTitle = "Call No : " & Main.nCallRegNo

' Set the Toolbar Shadow
    AC.SetElevation(ActionBar, 8dip)


    ABHelper.Initialize
    ABHelper.ShowUpIndicator = True
    ActionBar.InitMenuListener 'If this is not added then the Back button on the left side of the Toolbar is not working

    EdtSVRno.InputType = EdtSVRno.INPUT_TYPE_NUMBERS
    EdtSVRno.Gravity = Gravity.CENTER_HORIZONTAL
    EdtSVRno.Text = 0

    EdtSVRdate.Text=DateTime.Date(DateTime.Now)
    EdtSVRdate.Enabled = False  'Making SVR Date Read Only
    EdtSVRdate.Gravity = Gravity.CENTER_HORIZONTAL

End Sub

Sub Activity_Resume
    If reqManager.IsInitialized = False Then
        reqManager.Initialize("SvrNumber", Main.RdcServerIP) ' The IP of the machine running JAVASERVER
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub    ActionBar_NavigationItemClick
    Activity.Finish
End Sub
 
Last edited:
Upvote 0

Anser

Well-Known Member
Licensed User
Longtime User
Thank you very much Erel.:)

That solved the problem.:)

I understood my mistake. While initializing RDC, instead of giving the Activity Module's name (OR Me) , I used the Layout File's name.:confused:

Usually, I used to have both the Activity and Layout file with the same name, so it worked smoothly. This is the first time that I had an activity with a name different from the layout file name.;)

Thank you so much.:)

Regards
Anser
 
Upvote 0
Top