Android Question the parameter quetion for jRDC client

T.T Wang

Member
Licensed User
for client/sever, it is hard to interrupt to debug.
So I’m still puzzled for a the parameter passing to java server.

for example, I need to insert a new record, and passing 3 parameter, id is auto increase.
1、How many symbol “?” must be written in it?
2、Dim cmd As DBCommand = CreateCommand("insert_Help", Array(null, phonenumber, PID, password))
"null" must be put in to ocuppy the place?

sever config file:
sql.insert_Help=INSERT INTO Students (id, phonenumber, PID, password) VALUES (?, ?, ?, ?)

client:
Sub InsertRecord (phonenumber As String, PID as String, password as String)
Dim req As dbrequestmanager = CreateRequest
Dim cmd As DBCommand = CreateCommand("insert_Help", Array(null, phonenumber, PID, password))
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)
'work with result
req.PrintTable(res)
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
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
Return cmd
End Sub
 

T.T Wang

Member
Licensed User
for client/sever, it is hard to interrupt to debug.
So I’m still puzzled for a the parameter passing to java server.

for example, I need to insert a new record, and passing 3 parameter, id is auto increase.
1、How many symbol “?” must be written in it?
2、Dim cmd As DBCommand = CreateCommand("insert_Help", Array(null, phonenumber, PID, password))
"null" must be put in to ocuppy the place?

sever config file:
B4X:
sql.insert_Help=INSERT INTO Students (id, phonenumber, PID, password) VALUES (?, ?, ?, ?)
client:
B4X:
Sub InsertRecord (phonenumber As String, PID as String, password as String)
    Dim req As dbrequestmanager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("insert_Help", Array(null, phonenumber, PID, password))
    
    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)
        'work with result
        req.PrintTable(res)
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    
    j.Release
    
End Sub

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
    Return cmd
    
End Sub
 
Top