Android Question jRDC2 - someone has a complete sample project ?

achtrade

Active Member
Licensed User
Longtime User
Finally I have running my jRDC2 server, now I need to test the select, update, etc statements using jRDC2.

Thanks.
 

Alexander Stolte

Expert
Licensed User
Longtime User
I do not understand why so many still have problems with it, erel has already explained it best possible. look at the jRDC2 thread.

Step 1:

scroll down to "Client configuration" is the part for your Device.

Step 2:

read the numbers and read the explanations

Step 3:

copy and paste it. dont forget read the explanations

Step 4:

pass it to your configuration file on the server. If you have a SELECT statement with the name "sql.justselect=" then you need the code snip from "
GetRecord"

B4X:
 Dim cmd As DBCommand = CreateCommand("justselect", Array(id))

I hope I helped you, everything you need you already had, you just need to read.
Greetings

EDIT: UPDATE, DELETE, INSERT statements you need the
B4X:
Sub InsertRecord (Name As String)
code snip.
 
Upvote 0

achtrade

Active Member
Licensed User
Longtime User
I read everything, but in that threat there are only pieces of code, I need the full project to know how to call each sub and how to handle the result
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
okay.

add this to a service, this is the best , method

B4X:
Sub CreateRequest As DBRequestManager
   Dim req As DBRequestManager
   req.Initialize(Me, rdcLink)
   Return req
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

Sub GetRecord (id As Int)
   Dim req As DBRequestManager = CreateRequest
   Dim cmd As DBCommand = CreateCommand("select_animal", Array(id))
   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)

'i handle it with a for each loop. In this loop, it is easy to add the result for example to a sqlite database.

dim theresultinstring as string
For Each content1() As Object In res.Rows

theresultinstring = content1(res.Columns.Get("id")) '"id" here you put the column name from the item from the result with the column name from your online database.
           

            Next

   Else
       Log("ERROR: " & j.ErrorMessage)
   End If
   j.Release
End Sub

and how call this?

easy:
B4X:
    CallSubDelayed(theservice, "GetRecord")
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
jRDC2 is powerful. I use it in my social media app, because, i can develope easy the IOS Version with it and can expand it with ABMaterial for a web interface. This safe time and costs. And it is fast, this is a important point.
 
Upvote 0

achtrade

Active Member
Licensed User
Longtime User
Just one final question, every time I change the config.properties file and compile a new .jar, do I have to kill the program and restarted again in the VPS ?
 
Upvote 0
Top