Recent

Author Topic: App crash when running jMsSqlJDBCConnection.ExecuteQuery inside jAsyncTask  (Read 1783 times)

Thyphoon

  • New Member
  • *
  • Posts: 36
When I use jMsSqlJDBCConnection.ExecuteQuery (it doesnt matters the size of the query) inside a jAsyncTask the aplication crashed, in the logcat I can see this:

Code: Pascal  [Select][+][-]
  1. E/JavaBinder(  795): !!! FAILED BINDER TRANSACTION !!!
  2. W/ActivityManager(  795): Exception thrown during pause
  3. W/ActivityManager(  795): android.os.TransactionTooLargeException
  4. W/ActivityManager(  795):       at android.os.BinderProxy.transactNative(Native Method)
  5. W/ActivityManager(  795):       at android.os.BinderProxy.transact(Binder.java:496)
  6. W/ActivityManager(  795):       at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:932)
  7. W/ActivityManager(  795):       at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1336)
  8. W/ActivityManager(  795):       at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:4538)
  9. W/ActivityManager(  795):       at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:4239)
  10. W/ActivityManager(  795):       at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:4726)
  11. W/ActivityManager(  795):       at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:16947)
  12. W/ActivityManager(  795):       at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:16820)
  13. W/ActivityManager(  795):       at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:17592)
  14. W/ActivityManager(  795):       at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:17096)
  15. W/ActivityManager(  795):       at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)

If I run the query in the main app it works perfectly but the app seems stuck until it finish.

Can someone help me?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607

We need a new buid-in  "ExecuteQueryAsync"   method!  I will try some  implementation.....

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607

Yes! already exists an "ExecuteQueryAsync"  !!!!  You are lucky!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Thyphoon

  • New Member
  • *
  • Posts: 36
Did you already implement it??

jesus thats really fast!

I have to update the entire package right?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607
Quote
I have to update the entire package right?

I think, no...  this method already exists .....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Thyphoon

  • New Member
  • *
  • Posts: 36
for real??

mmmmm let me see....

I dont find it, anywhere in unit mssqljdbcconnection, where is it declared?
« Last Edit: April 10, 2020, 08:38:26 pm by Thyphoon »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607

Sorry...  I will updated it from my system.... [wait...]
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Thyphoon

  • New Member
  • *
  • Posts: 36

Sorry...  I will updated it from my system.... [wait...]

Thank you! Ill wait then.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607

Done!

Modified Files:

"...\lazandroidmodulewizard\android_bridges"

mssqljdbcconnection.pas
laz_and_controls_events.pas


"...\lazandroidmodulewizard\android_wizard\smartdesigner\java

jMsSqlJDBCConnection.java
jMsSqlJDBCConnection.native

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Thyphoon

  • New Member
  • *
  • Posts: 36
Sorry I cant get it to work !_!

1 - How can I check if the query finished?
2 - After I call ExecuteQueryAsync how can I recover the query result?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607

Handling the component events.... [messageStatus] 
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Thyphoon

  • New Member
  • *
  • Posts: 36
sorry Iam dumb, can you provide an example?

Are you talking about: procedure OnExecuteQueryAsync(Sender:TObject;messageStatus:string);

if so it si correct to do

Code: Pascal  [Select][+][-]
  1. procedure TMain_Menu.OnExecuteQueryAsync(Sender:TObject;messageStatus:string);
  2. begin
  3.   ShowMessage('it works!');
  4.   message:=messageStatus;
  5. end;

in my app?

please Iam really frustated about this.

I think there is something missing, I can find this events published

Code: Pascal  [Select][+][-]
  1.     property OnExecuteQueryAsync: TOnMsSqlJDBCConnectionExecuteQueryAsync read FOnExecuteQueryAsync write FOnExecuteQueryAsync;
  2.     property OnOpenAsync: TOnMsSqlJDBCConnectionOpenAsync read FOnOpenAsync write FOnOpenAsync;
  3.     property OnExecuteUpdateAsync: TOnMsSqlJDBCConnectionExecuteUpdateAsync read FOnExecuteUpdateAsync write FOnExecuteUpdateAsync;

but they are not available in the visual object, and I try to handle OnExecuteQueryAsync, but it seems it is not called at all...

also when doing  jMsSqlJDBCConnection1.ExecuteQueryAsync('Query here') I dont see anything logged in logcat.
« Last Edit: April 13, 2020, 04:30:55 am by Thyphoon »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607
Quote
but they are not available in the visual object, and I try to handle OnExecuteQueryAsync, but it seems it is not called at all...

1) re-install de package  "tfpandroidbridge_pack.lpk"

2) "Run" --> "Clean up and Build "    to clear/reset your project....

The param "messageStatus"  contains your data [or some message error....]
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Thyphoon

  • New Member
  • *
  • Posts: 36
Sorry but still no go:

I place this in a button onclic procedure:

Code: Pascal  [Select][+][-]
  1. procedure TMain_Menu.jButton7Click(Sender: TObject);
  2. begin
  3.      //jAsyncTask1.Execute;
  4.    message:='';
  5.    jMsSqlJDBCConnection1.ServerIP:='localhost';
  6.    jMsSqlJDBCConnection1.UserName:='sa';
  7.    jMsSqlJDBCConnection1.Password:='password';
  8.    jMsSqlJDBCConnection1.DatabaseName:='database';
  9.    if jMsSqlJDBCConnection1.Open() then
  10.    begin
  11.       LogMessage('Connecion openned');
  12.       jMsSqlJDBCConnection1.ExecuteQueryAsync('SELECT COUNT(*) FROM tarCustomer');
  13.       LogMessage('Asyc eXecuted');
  14.       //startProgress:= 0;  //out param !
  15.       LogMessage('Dialog Start');
  16.       process:=False;
  17.       //jDialogProgress1.Start; //or Show
  18.    end
  19. end;  

message is a global string var.

and I put this in the OnExecuteQueryAsync procedure of jMsSqlJDBCConnection1

Code: Pascal  [Select][+][-]
  1. procedure TMain_Menu.jMsSqlJDBCConnection1ExecuteQueryAsync(Sender: TObject;
  2.   messageStatus: string);
  3. begin
  4.   message:=messageStatus;
  5.   LogMessage('Runned event!, message result='+messageStatus);
  6. end;    

but nothing happens, in logcat I see

Code: Pascal  [Select][+][-]
  1. I/Main_Menu(20966): Connecion openned
  2. I/Main_Menu(20966): Asyc eXecuted
  3. I/Main_Menu(20966): Dialog Start
  4. I/Choreographer(20966): Skipped 40 frames!  The application may be doing too much work on its main thread.

but the message var never get the messageStatus value and "'Runned event!, message result=" never get logged in logcat.

It is as if the event never get fired, Iam doing something wrong?
« Last Edit: April 14, 2020, 03:52:50 am by Thyphoon »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1607

Sorry... I will try some fix!
[in fact, I don't have a server installed here ...
so, I will try to check for any logic error in java code]
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018