Hello
Just tested simple android client with jrdc2 similarly to Erel's example
Creating a table works; inserting records works; select doesn't return anything
this is config file for jrdc2 server:
This is code on b4a:
GetOneRecord or GetRecord don't retrieve values.
Log on java server tells me it received command:
or:
But if i put a breakpoint in b4a on log line, watching 'res' it is empty
If I uncomment req.printtable I get error
Can anyone help?
When I use old rdc everything works well.
Thanks
Just tested simple android client with jrdc2 similarly to Erel's example
Creating a table works; inserting records works; select doesn't return anything
this is config file for jrdc2 server:
B4X:
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/mytest?characterEncoding=utf8
User=root
Password=
ServerPort=17178
#Debug=true
#commands
sql.create_table=CREATE TABLE if NOT EXISTS `animals` (`id` INT(11) NOT NULL auto_increment, `name` varchar(30), `image` blob, PRIMARY KEY (`id`))
sql.insert_animal=INSERT into animals VALUES (null, ?,?)
sql.select_animals=SELECT * FROM animals
sql.select_one_animal=SELECT * FROM animals where id = ?
This is code on b4a:
B4X:
Sub Process_Globals
Private const rdcLink As String = "http://192.168.58.94:17178/rdc"
Type DBResult (Tag As Object,columns As Map, rows As List)
Type DBCommand (Name As String, Parameters() As Object)
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
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 CreateTable
Dim cmd As DBCommand = CreateCommand("create_table", Null)
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd),Null)
wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log("Inserted successfully")
End If
j.release
End Sub
Sub InsertRecord (Name As String)
Dim cmd As DBCommand = CreateCommand("insert_animal",Array(Name,Null))
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd),Null)
wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log("Inserted successfully")
End If
j.release
End Sub
Sub GetOneRecord(idt As Int)
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_one_animal", Array(idt))
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)
Log("done one record")
'req.PrintTable(res)
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
Sub GetRecord
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_animals", Null)
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)
Log("Done records")
'req.PrintTable(res)
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
Sub BntEnd_Click
Activity.Finish
End Sub
Sub BtnTestRead_Click
GetRecord
End Sub
Sub BtnTestCreate_Click
CreateTable
End Sub
Sub BtnTestInsert_Click
InsertRecord("fox")
End Sub
Sub BtnTestReadOne_Click
GetOneRecord(1)
End Sub
GetOneRecord or GetRecord don't retrieve values.
Log on java server tells me it received command:
B4X:
Command: query: select_one_animal, took: 1ms, client=192.168.58.91
B4X:
Command: query: select_animals, took: 1ms, client=192.168.58.91
If I uncomment req.printtable I get error
B4X:
Error occurred on line: 123 (DBRequestManager)
java.lang.NullPointerException
Can anyone help?
When I use old rdc everything works well.
Thanks