Page 1 of 1

Can anyDAC be used over Internet?

Posted: Sun 22 Dec 2013 15:29
by docH
I'm trying to find a way to make a Delphi application communicate with a mySQL database hosted on my external web server (on my ISP).
So far, as a test, I have managed to put a small bit of php on the web server that runs a query against the database and returns some results. By navigating to it in my browser I can see the results in my web browser.

Now I want to do the same thing from delphi. Ideally I want Delphi to generate some sql, send it to the database and have the results interpreted in some way and processed by Delphi. Essentially I'm trying to take one of my applications that uses a local SQLite database and convert it to use mySQL over the Internet.

Is this the sort of thing AnyDAC can do?
Easily?
Anyone got any suggestions as to best way to achieve what I want

:?:

Re: Can anyDAC be used over Internet?

Posted: Mon 23 Dec 2013 07:10
by AndreyZ
Yes, you can use MyDAC to work with your MySQL server via Internet. You can try using MyDAC Trial Edition and check whether it is appropriate for you. MyDAC Trial Edition is available at http://www.devart.com/mydac/download.html
We do not develop AnyDAC.

Re: Can anyDAC be used over Internet?

Posted: Mon 23 Dec 2013 16:19
by davidmarcus
If the hosting company allows external access to MySQL, then this is no different from connecting to a local MySQL server. You just enter the hostname and port, and connect. My hosting company whitelists my IP address, so I can connect. Or, some hosting companies may require that you open a SSH tunnel to forward the port. Or, there may be other approaches that will work.

Re: Can anyDAC be used over Internet?

Posted: Tue 24 Dec 2013 10:08
by docH
>If the hosting company allows external access to MySQL

And if they don't...? Would I be wasting money buying a professional connectivity program? Thats really what I needed to know.
What I don't really understand is that I can get my browser to run a php script on the web server, interrogate the database and return results. Why does it appear so difficult to get Dephi to do the same?

Re: Can anyDAC be used over Internet?

Posted: Tue 24 Dec 2013 13:23
by docH
AndreyZ wrote:Yes, you can use MyDAC to work with your MySQL server via Internet. You can try using MyDAC Trial Edition and check whether it is appropriate for you. MyDAC Trial Edition is available at http://www.devart.com/mydac/download.html
We do not develop AnyDAC.
I downloaded it and tried the demo.
First I had to play around with paths as it couldn't find DavDemo.inc or IDEVer.inc
Finally got the demo working and tried the ConnectDialog example. Filled in the correct values for my server and database, (taken from Filzilla that connects to the server OK).
The demo gave me a 'exception class socket error - cannot connect to server on host xxxx, connection timed out' eror.

Does this mean that MyDAC can't in fact connect to an external server?

Re: Can anyDAC be used over Internet?

Posted: Tue 24 Dec 2013 13:31
by docH
The actual sequequence of errors was...

class socketException Cannot connect to server on host xxx : connection timed out

MyDAcDemo raised exception class EMySQLExceptions with message cannot connect to server on host xxx. connection timed out

Calss EMyError raised exception class EMySQLExceptions with message cannot connect to server on host xxx. connection timed out

class EMySQLException with message 'Lost connection to MySQL server during query. Error writing to the connection: Invalid socket.

Connection timed out

Re: Can MyDAC be used over Internet?

Posted: Tue 24 Dec 2013 13:55
by davidmarcus
Did you check with the hosting company to see if they are blocking the MySQL port at the firewall? I connect to MySQL over the Internet all the time using MyDAC. Can you connect using MySQL Workbench?

Re: Can anyDAC be used over Internet?

Posted: Tue 24 Dec 2013 14:00
by davidmarcus
docH wrote:>If the hosting company allows external access to MySQL

And if they don't...? Would I be wasting money buying a professional connectivity program? Thats really what I needed to know.
What I don't really understand is that I can get my browser to run a php script on the web server, interrogate the database and return results. Why does it appear so difficult to get Dephi to do the same?
Browsers use the HTTP port. The MySQL server runs on a different port. It has to so the computer knows whether the incoming message should go to MySQL or to Apache. The firewall on the system will block some ports and allow access to other ports. On a webserver, the HTTP port must be open. You need to ask your hosting company what access they allow.

I think there is a way to use a PHP script to let your app communicate with MySQL, but this is more cumbersome than a direct connection. The MyDAC documentation may discuss this; I don't recall. I just make sure I pick a hosting company that allows external connections. Many do, if not by opening a port, then by letting you tunnel (since they'd rather open the SSH port than the MySQL port).

Re: Can anyDAC be used over Internet?

Posted: Tue 24 Dec 2013 16:35
by docH
Thank you. I am with Zen.

I did ask them about connecting to the database and this was their reply

"It is not possible for a remote program to connect to a database on your cpanel server. It is setup in this manner for security, it stops third parties connecting to databases and causing problems
for all users. The relevant database can only be connected to locally on the cpanel."

So maybe it can't be done with Zen?
Which ISP do you use that lets you connect?

Re: Can anyDAC be used over Internet?

Posted: Tue 24 Dec 2013 16:40
by davidmarcus

Re: Can anyDAC be used over Internet?

Posted: Tue 24 Dec 2013 17:02
by docH
Thanks, maybe its worth it for this application to host my database with them and then use myDac to connect.
I'll look into it.
Cheers

Re: Can anyDAC be used over Internet?

Posted: Wed 25 Dec 2013 07:00
by AndreyZ
If you cannot access your MySQL server directly, you can use HTTP tunneling to overcome this problem. For this, you should deploy the tunnel.php script (which is supplied with MyDAC) on the web server. It allows access to MySQL server using HTTP tunneling. The script must be available through the HTTP protocol.
You can find more detailed information about possible ways of connecting to MySQL server in the "Network Tunneling" article of the MyDAC documentation ( http://www.devart.com/mydac/docs/network_tunneling.htm ).