Lazarus

Programming => Operating Systems => Android => Topic started by: amartitegui on November 15, 2017, 04:37:53 pm

Title: Android + Mysql...
Post by: amartitegui on November 15, 2017, 04:37:53 pm
Has anyone made something with lazarus-android with mysql?
Tsqlconnector wont work? what external library could be used?
I know Oracle has connector/j & connector/node.js
but...

Any comments helpfull.
thanks
Title: Re: Android + Mysql...
Post by: Handoko on November 15, 2017, 05:04:33 pm
You can try jSqliteDataAccess and jSqliteCursor.

FYI, there are many demos you can try and see how they work. They're inside your LAMW_folder\trunk\demos.
Title: Re: Android + Mysql...
Post by: amartitegui on November 15, 2017, 05:47:44 pm
But can connect to Mysql server?
I allready have Mysql server running for many machines changing data at factory.
Just want to Make tablets been able to see data too.
With B4A there is a mysql conenctor and tested and worked fine.
The interesting part of it uits that i have created some application modules for slower machines with lazarus. And event Im thinking about conventing the whole project to lazarus.
The real usefull part of android with lazarus is to use same classes and functions. full units. within android program. Even if i gotta change the controls (regular Os buttons, etc).... well that does not worries me.
So, Mysql it soeems important to the idea. Thats why i asked.
As I know there are mysql connectors for java...
well if someone know something.... thankfull
Title: Re: Android + Mysql...
Post by: jmpessoa on November 15, 2017, 06:18:45 pm


What about  access your server ( Mysql  or any...) via http?
Title: Re: Android + Mysql...
Post by: amartitegui on November 15, 2017, 07:04:09 pm
Its a solution. or it may be.

Other may be..:
Zeos? anyone tryied with android?
also read something about MorMot.... dont know if it works though ...
and have a couple of other things i want to check.

but it's possible to arrange something eith http:... using synapse. 'cause synapse works within lazarus+android right?
I allready have something built with synapse that may work.
Title: Re: Android + Mysql...
Post by: amartitegui on November 15, 2017, 07:11:20 pm
Zeos uses external connector.... so one down.
Title: Re: Android + Mysql...
Post by: amartitegui on November 16, 2017, 07:23:23 am
NOpe... as far a as I've seen no way, unless webserivce/http
thanks
Title: Re: Android + Mysql...
Post by: jmpessoa on November 16, 2017, 04:49:33 pm

Quote
NOpe... as far a as I've seen no way, unless webserivce/http ....

A simple "CGI/Rest/RestFull"  is enough.....

In fact what you need is a  mySQL ".so" client for android ....
[I know there is a ".so" firebird client for android... but I never tested it...]
Title: Re: Android + Mysql...
Post by: amartitegui on November 17, 2017, 12:40:43 pm
foun this interesting matter bout  synopse/mormot.
Have you ever try to work with mormot?

http://blog.synopse.info/post/2013/09/19/FreePascal-Lazarus-and-Android-Native-Controls
Title: Re: Android + Mysql...
Post by: amartitegui on November 17, 2017, 12:42:53 pm
Also found somthing like this to try.
https://github.com/0x-ff/libmysql-android
Title: Re: Android + Mysql...
Post by: amartitegui on November 17, 2017, 01:49:06 pm
Furthermore, take a look at this guy's info.
Very interesting... and maybe someone also needs o its interested in this.
https://mymegabyte.com/2011/03/cross-compile-libmysql/

got to it from: http://www.qtcentre.org/threads/56202-mysql-plugin-on-android-requires-libmysqlclient_r-so-built-with-android-toolchain
Title: Re: Android + Mysql...
Post by: amartitegui on November 17, 2017, 01:54:08 pm
and... finaly yes.
Im gonna try all that stuf or compile (or try to compile the lib)
found many info about it using NDK.
Title: Re: Android + Mysql...
Post by: amartitegui on November 17, 2017, 06:33:32 pm
I thought I got it.
Mysql found library.
BUT and its a big BUT, there is an error using SQLDBLaz. When compiling appears the famous

Messages, Hints: 2
Verbose: Selected chip architecture: armeabi-v7a
Verbose: Taking libraries from folder: C:\lamw\projects\ALFONSO_TEST_1\test_mysql\libs\armeabi-v7a
Verbose: Found library: libcontrols.so
Note: Duplicate unit "controls" in "controls", orphaned ppu "C:\lamw\projects\ALFONSO_TEST_1\test_mysql\obj\controls\controls.o"
Note: Duplicate unit "controls" in "LCLBase 1.7", ppu="C:\lamw\laz4android\lcl\units\arm-android\controls.ppu", source="C:\lamw\laz4android\lcl\controls.pp"
Compile package CodeTools 1.0.1: Aborted
Compile package LCL 1.7: Exit code 1, Errors: 1
gtk2cellrenderer.pas(30,3) Fatal: Cannot find gtk2 used by Gtk2CellRenderer of package LCL.
Ideas?

Title: Re: Android + Mysql...
Post by: amartitegui on November 17, 2017, 06:46:51 pm
Should I go with Zeos?
Title: Re: Android + Mysql...
Post by: amartitegui on November 17, 2017, 07:03:02 pm
Uses LCL too.
 :'(
Title: Re: Android + Mysql...
Post by: jmpessoa on November 17, 2017, 08:28:00 pm

Yes, LCL not is supported in LAMW ... so we need a core/raw ".so"  for arm/android or x86/android,  etc...

but,  MorMot + LAMW is possible!

There is a demo [by DonAlfredo] here:

https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/demos/GUI/AppmORMotDemo1


Title: Re: Android + Mysql...
Post by: A.S. on November 17, 2017, 09:39:39 pm
I thought I got it.
Mysql found library.
BUT and its a big BUT, there is an error using SQLDBLaz.

You should not use SQLDBLaz package. Instead you need units for fcl-db: sqldb, mysqlXXconn (where XX is your libMySql version), etc.
Title: Re: Android + Mysql...
Post by: amartitegui on November 18, 2017, 12:40:24 pm
Mmmmmm you mean... use just the component units instead of the pakage rigth?
Necer thought of it. Gotta check also if they dont include lcl... but its a nice idea
Thanks. Gonna try.
I was making some tries creating the app without LAWN Too. But apk building its a pain in the ass.
Cant get it properly working.
Only got to buil .ap_ but stuck with .dex and signing. Mainly i think because of the dex part.
Title: Re: Android + Mysql...
Post by: amartitegui on November 20, 2017, 03:32:11 pm
Jmpessoa I think that, as A.S said it may work with LAWM. using the units and not the package (felt kinda stupid 'cause I do it all the time with nongraphical classes/units) It compiles, and it builds .APk.
But i think the library is not correct. I've checked and its buit for x86 android and api 14. Im running API19 and arm7. So it gives me an error (catched as exception) runtime.
Checked and should work. Iges its library. So to build library ....

Someone with experience compiling with android ndk?
I need to compile  libmysqlclient_r.so, libmysqlclient.so and libmysql.so properly for arm-7.
I know that its possible to compile with android NDk but have no experience at all.
anyone?
thanks
Title: Re: Android + Mysql...
Post by: jmpessoa on November 23, 2017, 06:09:26 pm
Quote
I need to compile  libmysqlclient_r.so, libmysqlclient.so and libmysql.so properly for arm-7.

Can you come up with  "C" code [localization] ?
Title: Re: Android + Mysql...
Post by: amartitegui on December 01, 2017, 05:20:03 pm
Sorry I've been on working trip.

Im back.
I think I built a lib , and also i have another allready built.
I installed lawm in ubuntu 17, 64 bit.
Managed to have all working.
made a simple prog test.
compiled.... everything green... should be fine.... but i get:

Ventana de Mensajes, Sugerencias: 2
Verbose: Selected chip architecture: armeabi-v7a
Verbose: Taking libraries from folder: /home/osboxes/Documents/LAZ_droid_projects/TEST_droid_1/Test_mysql_14_1/libs/armeabi-v7a
Verbose: Found library: libcontrols.so
Note: Unidad duplicada "controls" en "test_mysql_14", orphaned ppu "/home/osboxes/Documents/LAZ_droid_projects/TEST_droid_1/Test_mysql_14_1/obj/controls/controls.o"
Note: Unidad duplicada "controls" en "LCLBase 1.8.0.5", ppu="/home/osboxes/.lazarus/lib/LCLBase/units/arm-android/controls.ppu", source="/usr/share/lazarus/1.8.0RC5/lcl/controls.pp"
Compilar proyecto, OS: android, CPU: arm, Objetivo: /home/osboxes/Documents/LAZ_droid_projects/TEST_droid_1/Test_mysql_14_1/libs/armeabi-v7a/libcontrols.so: Éxito
Building APK... : Éxito
Installing APK... : Éxito
Starting APK... : Éxito
Starting: Intent { cmp=org.lamw.test_mysql_14_1/.App }
Error type 3
Error: Activity class {org.lamw.test_mysql_14_1/org.lamw.test_mysql_14_1.App} does not exist.

do you know why?
thanks

Title: Re: Android + Mysql...
Post by: amartitegui on December 01, 2017, 07:40:40 pm
I think library is not correct.
pain in the .... to build it
Title: Re: Android + Mysql... FINALLY got .so lib...
Post by: amartitegui on December 02, 2017, 12:29:57 pm
FInally I compilled So lib and as far as I know its ok.
I mounted in a simple program test withg LAMW.
The only problem I get is:
I put the limbysqlclient.so in folder libs.
but when I run the app it does not find the so.
Do i have to do something with the .so file?
I mean, just put the .so library in the libs folder .... I was assuming that it would be packed.... but maybe I need to do something else.
Anyone knows?
thanks
Title: Re: Android + Mysql...
Post by: amartitegui on December 02, 2017, 12:45:33 pm
NEVER MIND.
It works.
Its just that when compiling my so was called libmysql.so and not libmysqlclient.so
IT WORKS.
thanks anyway.
I will try to post something for this, so anyone can do it without so much trouble.
Title: Re: Android + Mysql...
Post by: jmpessoa on December 02, 2017, 03:53:29 pm

Good News  and Great Work!

Quote
I will try to post something for this, so anyone can do it without so much trouble.

Much appreciated!

Thank you!



Title: Re: Android + Mysql...
Post by: amartitegui on December 04, 2017, 05:45:07 pm
Ok, there it is.
I will write a tuto, or something similar.
But here. If anyone needs the SO for android of mysql :

https://mega.nz/#F!sbATBbjL!l-Uc0hpfg9-XwJDb3Vc_mg
 
for android 19, 21, 23, and 24.
So library should be placed in project folder, /libs/armeabi-v7a (if using arm7)


How to use.
WITH LAMW:
IMPORTANT:  SkipLibraryVersionCheck:=true;
Doing so, I checked it works with TMySQL56Connection and TMySQL55Connection
DO NOT use the registered tool in SQLdb (uses LCL). Just declare the TMySQL56Connection, TSQLQuery,TSQLTransaction classes.


in Activity/form:
{DECLARATION OF USES}
uses
  Classes, SysUtils, AndroidWidget, Laz_And_Controls,
  mysql56conn,sqldb, And_jni, surfaceview, drawingview;

{PRIVATE DECLARATIONS}
private   
     MySQL56Connection1:TMySQL56Connection;
    SQLQuery1: TSQLQuery;
    SQLTransaction1: TSQLTransaction; 

And to use it... for example:

{PROCEDURES}

procedure TAndroidModule1.AndroidModule1ActivityCreate(Sender: TObject;
  intentData: jObject);
begin               
  try
     MySQL56Connection1:=TMySQL56Connection.Create(nil);
     MySQL56Connection1.SkipLibraryVersionCheck:=true;     
     ShowMessage('correcto');
     except
           ShowMessage('problema');
    end;       
end;

procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
     try     
      try
         SQLTransaction1:=TSQLTransaction.Create(nil);
         SQLQuery1:=TSQLQuery.Create(nil);
         SQLTransaction1.DataBase:=MySQL56Connection1;
         SQLQuery1.DataBase:=MySQL56Connection1;       
         SQLQuery1.Transaction:=SQLTransaction1;
           ShowMessage('So far so good');
        except
           ShowMessage('query transactor');
       end;
     with MySQL56Connection1 do
     begin
       DatabaseName:='YOUR DATABASE NAME';
       HostName:='YOUR HOST.IP OR ALIAS';
       Port:={PORT NUMBER WITHOUT QUOTES, ITS NUMBER NOT STRING};
       Password:='YOUR PASSWORD';
       UserName:='YOUR USERNAME';
     end;
      MySQL56Connection1.Open();
      MySQL56Connection1.Connected:=true;
    // ShowMessage('So far so good... still');   
  except
      On E :Exception do begin
      ShowMessage(E.Message);
    end;
    //ShowMessage('ERROR conection');
  end;

  if MySQL56Connection1.connected then begin
    try
      SQLQuery1.close;
      SQLQuery1.SQL.Text:='YOUR QUERY...FOR THIS WITH LIMIT 1';
      SQLQuery1.active:=true;
      SQLQuery1.Open;
      jTextView1.Text:=SQLQuery1.FieldByName('sql_field_name_1').value;
      jTextView2.Text:=SQLQuery1.FieldByName('sql_field_name_2').value;
      jTextView3.Text:=SQLQuery1.FieldByName('sql_field_name_3').value;
      jTextView4.Text:=SQLQuery1.FieldByName('sql_field_name_4').value;   
      SQLQuery1.Close;
    finally
    end;
   end;
end;     
Title: Re: Android + Mysql...
Post by: jmpessoa on December 04, 2017, 07:58:33 pm
Great!!

Here is my suggestion to configure  your "Application.mk"
Quote
APP_ABI := armeabi armeabi-v7a x86
APP_PLATFORM := android-19

No need for others 20, 21, etc...

Thank you!
Title: Re: Android + Mysql...
Post by: amartitegui on December 04, 2017, 09:43:03 pm
Thanks man. Will try
 ;)
Title: Re: Android + Mysql...
Post by: amartitegui on December 05, 2017, 07:36:50 am
jmpessoa, good morning.
Application.mk should be in Jini folder ...
you mean application.mk in the test project where I use the .so file? If so:
Cant find Application.mk in the project folder...
I see the Application Tab in project options, in LAMW project options which refers Android Manifest and Application.
I see manifest,  But cannot fin the file....

thanks
Title: Re: Android + Mysql...
Post by: jmpessoa on December 06, 2017, 03:53:30 am
Quote
you mean application.mk in the test project where I use the .so file

No!

"application.mk"  is used to configure the ".so" builder project [not LAMW project] ... that is, if you
have the "C" code to produce the ".so" using core NDK...
Title: Re: Android + Mysql...
Post by: turrican on December 13, 2017, 03:35:55 pm
IMHO You shouldn't connect to an external database directly (with TCP cipher better). It's better and easy to make an HTTP Rest api and publish methods to retrieve and put data.
Title: Re: Android + Mysql...
Post by: amartitegui on December 14, 2017, 11:54:38 am
I disagree... deeply.
It depends on the overall system u may have. just as any other database.
Im not running Mysql server hosted  on internet, nor I have (dont need it) web server...
I have a mysql server in a local machine, and use it to store datas from computers, pcls ....
running in LAN, host filter assigned to users in certain machines...

Dont see the need of creating a webserver, php ....

So, as I said... It depends on the system layout.
Title: Re: Android + Mysql...
Post by: turrican on December 14, 2017, 04:22:26 pm
Great, no problem :  ;)
Also IMHO it's not the best protocol to use over internet.
Title: Re: Android + Mysql...
Post by: thawinsak on February 18, 2019, 11:26:15 am
I connect  mariadb   notwork
and i connect postgresql   libpg.so.5  not work
help me please
Title: Re: Android + Mysql...
Post by: jmpessoa on February 19, 2019, 01:13:52 am
Get [MySQL57Bridge.rar] from the attachment [below] .... and install "mysql57bridge_pack.lpk"

an try the demo  "AppMySqlDemo1.rar" ......



Title: Re: Android + Mysql...
Post by: jmpessoa on February 19, 2019, 01:15:19 am
after install "mysql57bridge_pack.lpk"

try the demo  "AppMySqlDemo1.rar" [above]
Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 24, 2019, 04:31:43 am
Get [MySQL57Bridge.rar] from the attachment [below] .... and install "mysql57bridge_pack.lpk"

an try the demo  "AppMySqlDemo1.rar" ......
Hello, guys. How about this MySQL Bridge result? Is that works? What .so file I should use?
Title: Re: Android + Mysql...
Post by: jmpessoa on April 24, 2019, 04:54:02 am

Please, wait ... I need updated it!!!
Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 24, 2019, 05:03:34 am

Please, wait ... I need updated it!!!
Thanks!  :D
Title: Re: Android + Mysql...
Post by: jmpessoa on April 24, 2019, 06:31:28 am

Done!!

LAMW Introduce "FCL Bridges" component palette.....

[to hold FCL based libraries...]

Intall "fcl_bridges_pack.lpk"     .... from new folder "fcl_bridges"
 
NEW demo "AppFCLMySQL57ConnectionBridgeDemo1"

Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 24, 2019, 06:37:37 am

Done!!

LAMW Introduce "FCL Bridges" component palette.....

[to hold FCL based libraries...]

Intall "fcl_bridges_pack.lpk"     .... from new folder "fcl_bridges"
 
NEW demo "AppFCLMySQL57ConnectionBridgeDemo1"
Thank you  :D
Btw, where I can find the libmysql.so? Which one did you used?
Title: Re: Android + Mysql...
Post by: jmpessoa on April 24, 2019, 06:47:55 am

LAMW will handle automatically for you!!!

But you can look here:

\lazandroidmodulewizard\android_wizard\smartdesigner\fcl\libso
Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 24, 2019, 07:07:07 am

LAMW will handle automatically for you!!!

But you can look here:

\lazandroidmodulewizard\android_wizard\smartdesigner\fcl\libso
Handle automatically?!! That's awesome.
Thanks for a great job!
Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 25, 2019, 05:36:49 am
There are problems with new mysqlbridge and old mysqlbridge.
The problem looks the same, but the behavior is different. The old one it does do nothing when I do a query, no exception, just press the button and there's nothing. The new one is crashing at the app launch.

I tried the demo, it behaves the same way.  :)
I am using target JDK 1.8.0, SDK 27, NDK 10e, Ant 1.9.7, and Gradle 4.7.  :D

edit: I got the error, it said: "Database is not assigned". But when I looking into the mysql57connectionbridge unit, but I quite sure it's assigned. It's confusing. Hahaha...
Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 25, 2019, 09:15:39 am
I just added MySQL47ConnectionBridge.MySQL57Connection.Transaction := TSQLTransaction.Create(nil);, and it works, but that so weird, because if I added that in the mysql57connectionbridge unit in the fcl-brige_pack it doesn't work.  %)

Is that an FCL bug or something?

Update: I'm using my own unit, it just works. That's so weird.
Title: Re: Android + Mysql...
Post by: jmpessoa on April 25, 2019, 11:43:30 pm

Good!!!

I will try mimic your code!
and, of course, assign the credit to you!

[please, put your demo in some open/cloud drive!]

Thank you!



Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 26, 2019, 07:25:43 am

Good!!!

I will try mimic your code!
and, of course, assign the credit to you!

[please, put your demo in some open/cloud drive!]

Thank you!
Yeah, sure.
Title: Re: Android + Mysql...
Post by: AFFRIZA 亜風実 on April 26, 2019, 11:38:13 am
This is the demo drive link  :)

https://drive.google.com/open?id=1wwAWNFVIqppd7tO-CMp26tC8zLSxANdL (https://drive.google.com/open?id=1wwAWNFVIqppd7tO-CMp26tC8zLSxANdL)
TinyPortal © 2005-2018