Android Question RDC exits without error message

LéonE

Member
Licensed User
Longtime User
Hi Guys,

Sorry long story:

i'm busy with an app that has a local sqlite.db and a server sqlite.db
now i wanted to do some nice stuff.
1) get (after login) the reply from server that user exist and can connect with the device
in his/her hands.
NO problem that's working.
2) when the user is autorised he/she gets more data from server.
No problem That's working too.

BUT:
1) if i do these requests (user id check and some more data) one after the other the application hangs.
example: in Main 2 lines like
getuser_id
getsomething

this resolved with a timer (see code later). for me it shouldn't be like that

2) an option within the menu "Sync from server" does not function and the app exists.
here NO error is shown in ide (unfiltered log). No error in log from http service. Nothing.
However SOMETIMES is works.

Here are some codes/logs and settings:
c3p0 properties (not changed from standard):
c3p0.maxStatements=150
c3p0.maxIdleTime=1800
c3p0.idleConnectionTestPeriod=600
c3p0.checkoutTimeout=30000

B4A ide (log not filtered)
-------------------------------------------------
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
------------------------------------------------

log from service
B4A Remote Database Connecter (version 0.9)
loading: C:\B4AORDER\config.properties

Command: query: select_UserID, took 265ms, client=192.168.178.27
Command: query: select_something, took 265ms, client=192.168.178.27
if working (sometimes it does):
Command: query: select_somethingelse, took 16ms, client=192.168.178.27

B4X:
Sub GetUser_ID
    Req1=1
    cmd.Initialize
    cmd.Name = "select_UserID"
    cmd.Parameters = Array As Object(Uname,MyIpAdre)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub


Sub Getsomething
    Req1=2
    cmd.Initialize
    cmd.Name = "select_something"
    cmd.Parameters = Array As Object(Uname)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

the item not working:
B4X:
Sub Getsomethingelse

    Req1=3
    Dim Ssql, dt,dt2 As String
    DateTime.DateFormat = "dd-MM-yyyy"
    now1 = DateTime.now
    dt = DateTime.Date(now1)
    Ssql="select datum from syncdata"

    dt2 = SQL.ExecQuerySingleResult (Ssql)
    If dt<>dt2 Then
        Ssql="update syncdata set datum='" & dt & "'"
        SQL.ExecNonQuery (Ssql)
        x=""
        cmd.Initialize
        cmd.Name = "select_somethingelse"
        cmd.Parameters = Array As Object(Uname)
        reqManager.ExecuteQuery(cmd, 0, Null)
   End If      

End Sub


With the timer this is functioning.

B4X:
Sub Timer1_Tick        'here i have interval 2000 (2sec)
    ' Do something
    TimerTotal=TimerTotal + timer1.Interval
    If TimerTotal=timer1.Interval Then
        GetUser_ID
    End If
    If TimerTotal=timer1.Interval*2 Then
    '    Log("Timer=2")
        Getsomething
    End If
    If TimerTotal=timer1.Interval*3 Then
        Getsomethingelse        ' not functioning
    End If
    If TimerTotal=timer1.Interval*4 Then
        timer1.Enabled=False
    End If
    If TimerTotal=timer1.Interval*5 Then
    '    Log("Timer = disabled")
      
    End If
End Sub

the access to the database is not the issue neither the lines in config.properties

sql.select_UserID=SELECT Uid, AppIp FROM users WHERE Uname = ? AND AppIP = ?
sql.select_something=SELECT max(nr) FROM mytable

NOT WORKING : sql.select_somethingelse=SELECT * from myothertable

(i even tried with all the fieldnames and not * = no difference)

hope someone can tel me how to handle this.
maybe c3p0 settings i really don't know anymore.

extra: I walked though with F8 (debugmode) it is like the procedure is to quick. i get all the data. No exit. is there a way to slowdown the server request?

Thanks!
 
Last edited:

LéonE

Member
Licensed User
Longtime User
Adding remark.
if i "pause" at WriteList(Command.Parameters, out2) in dbrequestmanager (Sub ExecuteQuery) and do the rest part with F8 (step by step debug) until arriving at Sub PrintTable than all goes OK.

i'm loading only 25 line from a database-table not much. that will ever become about 2000 (at least).

please help! I'm not familiar with this matter.

one more question:
the line cmd.Parameters = Array As Object(Name) i put name here but really don't need this parameter (for where clause)
how to handle this? do i write cmd.Parameters = Array As Object(Null)?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

LéonE

Member
Licensed User
Longtime User
Erel, This didn't help. it doesn't pass in the Sub JobDone(Job As HttpJob). there is an earlier exit. and i can't figure out where.


I restarted my PC this morning and got also this error message (in ide):


my configuration is now:
c3p0.maxStatements=150
c3p0.maxIdleTime=1800
c3p0.idleConnectionTestPeriod=6000
c3p0.checkoutTimeout=20000
c3p0.minPoolSize=1
c3p0.maxPoolSize=1

Please help...
 
Upvote 0

LéonE

Member
Licensed User
Longtime User
Erel, I did following:

I connected to an Oracle database. That Works! (pushed several times on synchronize)

in SQLite the programm stops.
it seems to be that the j.PostBytes(link & "?method=batch", ms.ToBytesArray) doesn't do the post
and therefor the app does not continue to the JobDone(Job As HttpJob)

I wrote log before and after the reqManager.ExecuteQuery(cmd, 0, Null) and it's comming there.
but for one or other reason there is no jobdone but the app exits without warning.

firsttime working
Before reqManager.ExecuteQuery(cmd, 0, Null)
between WriteInt(Limit, out2) and WriteList(Command.Parameters, out2)
After WriteList(Command.Parameters, out2)
After out2.Close
After j.PostBytes
After reqManager.ExecuteQuery(cmd, 0, Null)
HandleJob: 487
Tag: null, Columns: 6, Rows: 24
Colname(s): groepnr, KaartNr, MenuNr, omschrijving, prijs, TAXCode,

Secondtime
Before reqManager.ExecuteQuery(cmd, 0, Null)
between WriteInt(Limit, out2) and WriteList(Command.Parameters, out2)
After WriteList(Command.Parameters, out2)
After out2.Close
After j.PostBytes
After reqManager.ExecuteQuery(cmd, 0, Null)

No handlejob
no Tag
no colname(s)

hope this helps you more to find what's going on.
 
Last edited:
Upvote 0

LéonE

Member
Licensed User
Longtime User
Erel, i CAN/will. but it's not coming there. after the reqmanger.executequery it does the log(see above) and than even with step by step F8 the app stops. it looks like there is a total loss of the job.

it's a little unconventional but here it is.

B4X:
        If Job.JobName = "DBRequest" Then
            Dim Result As DBResult = reqManager.HandleJob(Job)
            reqManager.PrintTable(Result)

  If Job.Tag="MenuK" OR Req1=3 Then
                Dim strf1 As StringFunctions
                Dim Ssql, Str2,dt,dt2 As String
                    SQL.BeginTransaction
                    Try
                    For t= 1 To 999              
                        If Result1(t,1)<>"" Then
                            Str2="insert into MK values("
                            Str2 = Str2 & strf1.Mid(Result1(t,1),1,strf1.Len(Result1(t,1))-1)
                            Str2 = Str2 & ", "
                            Str2 = Str2 & strf1.Mid(Result1(t,2),1,strf1.Len(Result1(t,2))-1)
                            Str2 = Str2 & ", '"
                            Str2 = Str2 & strf1.Mid(Result1(t,3),1,strf1.Len(Result1(t,3))-1)
                            Str2 = Str2 & "', '"
                            Str2 = Str2 & strf1.Mid(Result1(t,4),1,strf1.Len(Result1(t,4))-1)
                            Str2 = Str2 & "', '"
                            Str2 = Str2 & strf1.Mid(Result1(t,5),1,strf1.Len(Result1(t,5))-1)
                            Str2 = Str2 & "', "
                            Str2 = Str2 & strf1.Mid(Result1(t,6),1,strf1.Len(Result1(t,6))-1)
                            Str2=Str2 & ")"  
                            SQL.ExecNonQuery(Str2)
                        Else
                            t=999   ' snif no exit for...
                        End If
                    Next
                    SQL.TransactionSuccessful
                    Catch
                    Log(LastException.message)
                    End Try
                    SQL.EndTransaction
                    DoEvents
                    ProgressDialogHide
            End If
end if
 
Upvote 0

LéonE

Member
Licensed User
Longtime User
something else.
i gave all actions a name reqManager.ExecuteQuery(cmd, 0, "NameOfrequest")
it seems to work. could that really be the issue?
also i had a query (local sqlite.db) before the reqmanger call. now i put this in job done.
can it be that there was somewere (memory or else) a confict?

is the moment and order of local queries and remote requests important?

because i had the error again and after placing code somewhere else it disappear.


I have to see tomorrow. I let you know.

Regards, Léone
 
Upvote 0

LéonE

Member
Licensed User
Longtime User
Shure. This code is when succes = true. But as strated before. The programm wan't arriving at jobsucces true or false.
See however the remark i wrote abobove, is there an order role of actions? Local and remote?

Send from tablet
 
Upvote 0

LéonE

Member
Licensed User
Longtime User
Erel,

It might be strange but: moving sql coding, for local checks, deletion and updates did the trick.
i had following:
1) check date and time in local db. (last sync)
2) if not today or older than half a day update date and time
3) delete from local db
4) call (with requestmanager) data on server
5) if succesfull than load all the server data into local db.

i changed it in: 4) 5) 3a) delete from local 3b) and update date time
with a check before would be nicer but doesn't work... that's why my question before, about order of actions.

so you can close this question, if you want. I know now:

first server job. reading data into memory of device
if jobsuccess than the rest. otherwise the app crashes and you're stuck with empty local db.

regards, Léone.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…