Android Question jDRC logs insert success but no data inserted on actual database

Mark Ryan Penafiel

Member
Licensed User
Longtime User
Good day, i am trying to follow the jDRC tutorial.
i have successful connection

In my config.properties
B4X:
sql.create_table
sql.select=select * from article
sql.insert=INSERT INTO article VALUES(?, ?)


in my
B4A

i have a button

B4X:
    Dim Days() As String
    Days = Array As String("Sunday", "Monday")
  
    InsertRecord(Days)

and a sub
B4X:
Sub InsertRecord (Name As String)
    Dim cmd As DBCommand = CreateCommand("insert",Array(Name, Null))
    Dim j As HttpJob = CreateRequest.ExecuteCommand((cmd), Null)
  
  
  
    Wait For(j) JobDone(j As HttpJob)
  
    If j.Success Then
        Log("Inserted successfully!")
    End If
    j.Release


End Sub

the log shos i inserted succesfully
but upon checking database, no data apears

also
can you give an example how to insert to database with multiple parameters or multiple columns

Thanks in advance
 

Mark Ryan Penafiel

Member
Licensed User
Longtime User
Yes there is none
 

Attachments

  • jrdc.PNG
    jrdc.PNG
    124.5 KB · Views: 237
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Their is an error in your code.

Change your code to:
B4X:
Dim Days() As Object = Array("Sunday", "Monday")
  
Wait For (InsertRecord(Days)) Complete (Result As Boolean)
If Result Then
 GetRecord
End If

Sub InsertRecord (Params() As Object) As ResumableSub
    Dim cmd As DBCommand = CreateCommand("insert",Params)
    Dim j As HttpJob = CreateRequest.ExecuteCommand((cmd), Null)
 
    Wait For(j) JobDone(j As HttpJob)
  
    If j.Success Then
        Log("Inserted successfully!")
    End If
    j.Release
    Return j.Success

End Sub

Sub GetRecord 
   Dim req As DBRequestManager = CreateRequest
   Dim cmd As DBCommand = CreateCommand("select", Null)
   'req.ExeucteQuery returns a HttpJob. The returned HttpJob is used as the sender filter.
   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

Does it work?
 
Upvote 0

Mark Ryan Penafiel

Member
Licensed User
Longtime User
did not work

here is the new error log

Error reading response: (ZipException) java.util.zip.ZipException: incorrect header check

thanks for the help
 
Upvote 0

Mark Ryan Penafiel

Member
Licensed User
Longtime User
error occurred at GetRecord

Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)

there are no other errors in the log. or should i check a textfile in the server to see the server side error
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Was the data inserted?

there are no other errors in the log. or should i check a textfile in the server to see the server side error
It depends on how you are running the server. If it is running from the IDE then you should check the logs there.

Change this line:
CreateCommand("select", Null)
To:
B4X:
CreateCommand("select", Array())
 
Upvote 0

Mark Ryan Penafiel

Member
Licensed User
Longtime User
no data inserted

the new codes is now

B4X:
Sub GetRecord
    Dim req As DBRequestManager = CreateRequest
   
    Dim cmd As DBCommand = CreateCommand("select", Array())
   
       
   
    'req.ExeucteQuery returns a HttpJob. The returned HttpJob is used as the sender filter.
    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


error still logs
Error reading response: (ZipException) java.util.zip.ZipException: incorrect header check
 
Upvote 0

Mark Ryan Penafiel

Member
Licensed User
Longtime User
my config.properties is

B4X:
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/test2?characterEncoding=utf8
User=root
Password=birdistheword978234
#Java server port
ServerPort=17178
#example of MS SQL Server configuration:
#DriverClass=net.sourceforge.jtds.jdbc.Driver
#JdbcUrl=jdbc:jtds:sqlserver://<server address>/<database>
#example of postegres configuration:
#JdbcUrl=jdbc:postgresql://localhost/test
#DriverClass=org.postgresql.Driver
#SQL COMMANDS
#sql.create_table=CREATE TABLE IF NOT EXISTS animals (\
#     id INTEGER PRIMARY KEY AUTO_INCREMENT,\
#     name CHAR(30) NOT NULL,\
#     image BLOB)
#sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
#sql.select_animal=SELECT name, image, id FROM animals
sql.create_table=CREATE TABLE article (col1 numeric(10,4) ,col2 text);
sql.select=select * from article
sql.insert=INSERT INTO article VALUES(?, ?)


i copied jRDC.jar to /home/taxmapping

my java path is /opt/jdk1.8.0_101/bin/java

run
nohup /opt/jdk1.8.0_101/bin/java -jar /home/taxmapping/jRDC.jar > nohup.out &


and have a succesful conection

http://serverip:17178/test


did i answer the question?
 
Last edited:
Upvote 0
Top