How to access MySQL database on local computer with Android App?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
kerbadoughazali
Posts: 10
Joined: Fri 28 Jul 2017 09:20

How to access MySQL database on local computer with Android App?

Post by kerbadoughazali » Fri 28 Jul 2017 09:24

Hello,
we have a local server (PC) in my company, there is a MySQL database and another Firebird database.
i want to develope an application that can access those databases from Android App using Delphi XE8 ?

Note: Xampp has been installed.
Thanks

kerbadoughazali
Posts: 10
Joined: Fri 28 Jul 2017 09:20

Re: How to access MySQL database on local computer with Android App?

Post by kerbadoughazali » Sun 30 Jul 2017 17:25

hello every body !,
no one can answer? where is DevArt ?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to access MySQL database on local computer with Android App?

Post by ViktorV » Mon 31 Jul 2017 08:09

UniDAC allows to connect to MySQL server from Android. To test this functionality, you can use our Mobile demo project. The project is located in the 'Demos\Mobile' folder relatively to the UniDAC demos installation path.
UniDAC allows you to connect to an available MySQL server. Check the availability of the MySQL server using the Telnet program:
Telnet.exe MySQLServerAdress MySQLServerPort
If the server is unavailable, please contact your system administrator to solve this task.
Note, Mobile Development is available only in Professional and Trial Editions, you can find information about this here: http://www.devart.com/unidac/editions.html
Currently, you cannot connect a Firebird server from Android using IBDAC. We started the process of implementing support for Android for Firebird in IBDAC. But according to the phrase from the official Firebird server "Android builds were not thoroughly tested, therefore they should be treated as experimental." we should thoroughly test this implementation, so unfortunately, we can't provide you the exact time frames.
You can connect to InterBase from an Android and iOS device. InterBase supports mobile operating systems starting from InterBase XE3 - exactly about this it was mentioned in 5.1 version release notes.

kerbadoughazali
Posts: 10
Joined: Fri 28 Jul 2017 09:20

Re: How to access MySQL database on local computer with Android App?

Post by kerbadoughazali » Mon 31 Jul 2017 11:49

Hi,
i successed connecting to a remote MySQL in an internet server,
but in local server i failed.
the screenshot with error: https://ibb.co/dyPt9k

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to access MySQL database on local computer with Android App?

Post by ViktorV » Mon 31 Jul 2017 14:26

When the TUniConnection.Server property is set to "localhost" or "127.0.0.1", there is an attempt to connect to MySQL server running on the device on which your program is running. Therefore, when setting the TUniConnection.Server property to localhost, MySQL server must be preinstalled, configured, and run on the local device.
Regarding the installation of MySQL server on mobile devices, we do not provide any recommendations. You can use any official version of the server.

kerbadoughazali
Posts: 10
Joined: Fri 28 Jul 2017 09:20

Re: How to access MySQL database on local computer with Android App?

Post by kerbadoughazali » Mon 31 Jul 2017 16:27

Did you mran that i must install MySQL into my Android device to let him connect to my PC server?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to access MySQL database on local computer with Android App?

Post by ViktorV » Tue 01 Aug 2017 09:12

If your Android device is on a local network with MySQL server - you should specify the local IP address of your MySQL server in the TUniConnection.Server property. If you want to be able to connect to MySQL server that is on your local network from outside, you should make MySQL server accessible from outside. This issue is not related to UniDAC functionality, but to the issues of system administration and network configuration. To get an answer to this question, please, contact your system administrators with the question how to make your MySQL server accessible from the Internet or ask the appropriate question at some specialized forums. Once your local MySQL server is accessible from outside, you should set the TUniConnection.Server and TUniConnection.Port properties to the correct values ​​equivalent to the external IP and MySQL server port.

kerbadoughazali
Posts: 10
Joined: Fri 28 Jul 2017 09:20

Re: How to access MySQL database on local computer with Android App?

Post by kerbadoughazali » Wed 02 Aug 2017 14:54

hello,
i want to access my local MySQL database using Wifi not from Internet.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to access MySQL database on local computer with Android App?

Post by ViktorV » Wed 02 Aug 2017 15:09

As we wrote earlier, in this case you should specify the local IP address of your MySQL server in the TUniConnection.Server property.

JensVitec
Posts: 9
Joined: Tue 25 Jul 2017 08:01

Re: How to access MySQL database on local computer with Android App?

Post by JensVitec » Tue 08 Aug 2017 07:53

You need to understand the concept of the IP address "127.0.0.1" that has the name "localhost".
Every single computer in the world (that has a netcard) has the IP address 127.0.0.1 (localhost).

As Viktor explained, you need to specify the unique IP address.

You state that you need to access the local computer, not on the internet. From the netcards point of view, there realy is no difference. Its all just "another computer with some ip address".

So you need to figure out which IP address your "local" machine has. To do this, start a DOS-prompt (by typing cmd in windows start thing). Once you have a DOS-prompt type "ipconfig" after hitting enter you will get some text, one of the lines is IP4 Address and on that line you can see what IP address your computer has (the computer with MySQL installed, this all must be run on).
I am guessing the IP Address will be 192.168.0.xxx or something close to that where xxx can be anything from 1 to 255.
This is the IP address you need in your Android App.
NOTE however, the IP address can change whenever you reboot the computer, as its most likely getting the IPAddress dynamically every time (it will almost always get the same, but that's not certain).

Just to clarify the "localhost" name or 127.0.0.1
If you have a computer, mobilephone, networkgadget, iPad, tablet, anything with a netcard in your hand, it will always have the ipdress 127.0.0.1 with the name localhost.
So when your android phone cannot find the database on "localhost" it saying it cannot find the database on itsself, which is correct.

Hope this clarifys

Jens

kerbadoughazali
Posts: 10
Joined: Fri 28 Jul 2017 09:20

Re: How to access MySQL database on local computer with Android App?

Post by kerbadoughazali » Wed 09 Aug 2017 13:53

Hi, id that ip in ipconfig: 192.168.8.100 but i can't access !
only localhost and 127.0.0.1 who connect.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to access MySQL database on local computer with Android App?

Post by ViktorV » Wed 09 Aug 2017 14:11

Please specify 192.168.8.100 is MySQL server IP or IP of your Android device. Please provide the full error message when attempting to connect to 192.168.8.100.


ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to access MySQL database on local computer with Android App?

Post by ViktorV » Wed 09 Aug 2017 15:01

The 'Access denied for user 'YourUserName'@'YourComputerName'' message is a server response to an authentication fail. This message means that no user with the 'YourUserName' name exists or you have entered an invalid password, or a user with the 'YourUserName' name has no server access rights from the 'YourComputerName' PC.
To solve the problem, you should add the necessary rights to the YourUserName account or create a user with the necessary rights. The needed information can be found in the MySQL reference manual (e.g.: http://dev.mysql.com/doc/refman/5.5/en/grant.html).

kerbadoughazali
Posts: 10
Joined: Fri 28 Jul 2017 09:20

Re: How to access MySQL database on local computer with Android App?

Post by kerbadoughazali » Wed 09 Aug 2017 15:51

i do it, from the PC it connect but from Android it dosn't connect.

Post Reply