Is it possible to connect to a remote MySQL database securely?

401 views
Skip to first unread message

Kieran Mason

unread,
Oct 19, 2015, 5:31:18 PM10/19/15
to AndroidScript
As the title says, is it possible to connect to a remote MySQL database, but kinda importantly, securely?

I know JavaScript wasn't initially developed for this purpose but I thought it'd be pretty cool to do so.

PHP can do it like so:
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname);
Obviously with the right variables

Java can do it with the JDBC DriverManager:

Last year, during my High School Computer Science coursework, I was relatively certain that I stumbled upon a jQuery library that allowed you to run SQL queries to locally hosted databases; I'm not sure of the legitimacy of this library as it didn't (and doesn't) seem very do-able.

Now, the next problem would be security. JavaScript can be easily seen as it is a client-sided language, as opposed to the likes of PHP, so any database details would be pretty much have the user staring at them, not something you'd want for keeping the database intruder-free...

Anyhow, the main thing I'm looking for here is some method of connecting to a remote database, be it in Java - somehow through DroidScript - or JavaScript if someone manages to concoct the magic to do so.
Just a thought for the day :)

Mc-CraftTime XGamer

unread,
Oct 20, 2015, 1:16:55 AM10/20/15
to AndroidScript
Hey Kieran Mason,

i had the same Problem... How the Hell to connect to an MYSQL Database...

With DroidScript itself its nearly impossible. Secured is it also not!


So i searched for some solutions and found AJAX.

AJAX works like the HTTPGet Example from DroidScript.
It Connects to an PHP Server and the PHP Server connects to the MySQL Database and gives you the Information with a HTTP Table.
Problem ist, that you cant use HTTP Tables in DroidScript, so you need to convert the PHP Server code, that it gives you the Information you want inside the HTTP File you "Get".

But i cant help you from now on, because i didnt tryed it ever out... Maybe i try today for you.

-XGamer-

Kieran Mason

unread,
Oct 20, 2015, 3:17:09 AM10/20/15
to AndroidScript
Awesome! Definitely sounds interesting, I can't believe I didn't spot AJAX when I was looking. I'll have a look into it tonight. Thank you for this :)

Paul Norman

unread,
Oct 20, 2015, 3:35:02 AM10/20/15
to AndroidScript
XGamer is on to it.

You can use DroidScript to craft a URL request to a PHP file on your server, which handles your MySql query there, and have remote PHP send back a JSON response to DroidScript.

Even use PHP locally on device to do things for DroidScript that DroidScript might never have enough demand to be be set up to do itself.

One local phone pure php server is available - Last updated 2015-10-18 to PHP 5.6.12
There are built in MySql and MySqli extensions.

You can download that app here:
https://play.google.com/store/apps/details?id=com.esminis.server.php

Author
(and a full list of available extensions etc):

https://bitbucket.org/esminis/server.php

Tautvydas Andrikys http://esminis.com

License:
Source code is licensed under the Apache License, Version 2.0

Reply all
Reply to author
Forward
Message has been deleted
0 new messages