Android Question [B4A] jRDC2 - Ambiguous error in debug mode

Q Candiani

Member
Licensed User
Longtime User
Hi, I am working in a B4A app wich interaction with a PostgreSQL DB. It uses the jRDC2 library. For developing reasons the server is mounted on LocalHost. The middle server developed with B4J works fine.

The problem is very strange. When I call some SQL request (no matter which one) from the B4A app in debug mode, sometimes, rise up errors about missing parameters or cast types. But, if I run de app in Release mode, these errors never appear and the same SQL requests work fine. Even more confusing, in debug mode, sometimes the same SQL request give me an error and other times not even though nothing has changed.

Any clue about this problem? I'm disoriented and it prevents me from testing the program in debug mode.

Thanks
 

Q Candiani

Member
Licensed User
Longtime User
Ok,

config.properties file: Sql sentence:

#Table: b003: Actualizamos la fecha de actualización de un proyecto en el server segùn su CUIP
#Input: last_login, cuip (where cuip is text)
#Return: True/False
sql.last_update_cuip_b003=UPDATE b003 SET last_login = CAST(? As TIMESTAMP) WHERE cuip = ?;

B4A code:
B4X:
'Set date_update as TIMESTAMP format
Dim date_update As String = fCom.str_date(version_local, True, 1)
'Starter.arg: It was define as public variant in module server Starter: Public arg As Object
Starter.arg = Array(date_update, Starter.CUIP)
'exe_sql_nonQuery: It was define as sub in the current Activity
exe_sql_nonQuery("last_update_cuip_b003")
wait for exe_sql_nonQuery_complete
LogColor("last_update_cuip_b003: " & Starter.nonQuery_success, Colors.Green)
If Starter.nonQuery_success = False Then
    Dim mensaje_error As String = "last_update_cuip_b003: db local"  & " - [Error]: " & LastException
End If

B4X:
Sub exe_sql_nonQuery (Name As String)
    Try
        LogColor("------Wait for exe_sql_nonQuery_complete...", Colors.Cyan)
        Dim cmd As DBCommand = fCom.CreateCommand(Name, Starter.arg)
        Dim j As HttpJob = fCom.CreateRequest.ExecuteBatch(Array(cmd), Null)
        Wait For(j) JobDone(j As HttpJob)
        If j.Success Then
            LogColor("Inserted successfully!",Colors.Cyan)
            Starter.nonQuery_success = True
        Else
            Starter.nonQuery_success = False
        End If
        j.Release
        Starter.nonQuery_many = Starter.nonQuery_many + 1
        Log("nonQuery_many: " & Starter.nonQuery_many)
    Catch
        Starter.nonQuery_success = False
        Log(LastException)
    End Try
    LogColor("------ exe_sql_nonQuery_complete: DONE", Colors.Cyan)
    CallSubDelayed(Me, "exe_sql_nonQuery_complete")
End Sub

Full error message (only when I run in debug mode, not in release mode):

ResponseError. Reason: org.postgresql.util.PSQLException: No se ha especificado un valor para el parametro 2., Response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 org.postgresql.util.PSQLException: No se ha especificado un valor para el parámetro 2.</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> org.postgresql.util.PSQLException: No se ha especificado un valor para el parámetro 2.</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Can something else overwrite Starter.CUIP or Starter.Arg? Event processing in Debug mode may happen a little different than in Release mode. Log the contents of Starter.Arg before Wait For(j) to ensure you are processing what you think you are processing.

Update: Actually log what's in DBCommand. This way you know what you are transferring.
 
Upvote 0

Q Candiani

Member
Licensed User
Longtime User
Yes, you are right! Someway, some parameters are loosing in debug mode. I do not know why.

When the app comes to the

B4X:
Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Name
    If Parameters <> Null Then
        cmd.Parameters = Parameters
    End If
    Return cmd
End Sub

only one of the two parameters remain. Surprisingly Starter.arg has lost one argument. But why? Perhaps it is convenient to declare the variable 'arg' as private in the current activity, do not you think?

UPDATE -Resolved?-: If I declare 'arg' variable as private in the current activity it seems to work fine. I am very grateful for the suggestion. Thank a lot.
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Surprisingly Starter.arg has lost one argument. But why?
Do other activities update Starter.Arg? Other Services? Other Events? If so, those could overwrite your settings. One should be careful when using Global variables, especially when writing to them from multiple places (if that is something that is happening here). Of course due to the nature of Debug mode, these issues may only present themselves in Debug mode, but should probably be resolved, just in case.
 
Upvote 0

Q Candiani

Member
Licensed User
Longtime User
Do other activities update Starter.Arg? Other Services? Other Events? If so, those could overwrite your settings.

These global variables do not seem to be altered in any code line from the first sub process to the end of the process. In fact, in the variable "starter.arg", from the two arguments lose one and keep the other, that is, the information is not replaced but "lost" some pieces. These global variables are widely used and necessary in the app. Because of this I try to monitor them and avoid this kind of problems. Hence my confusion and surprise.
Anyway, I do not understand very well why in Debug mode the application - and these variables in particular - behave differently from the Release mode.
 
Upvote 0
Top