SQL connection on Android SDK

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

SQL connection on Android SDK

Post by d.m.holdawayGA2553 »

my app works great on iphone and within simulator and on my desktop.

when i test the app within the Android SDK i get a fail to connect.

works on on everything else.

i am using version 2.2 in the android simulator and i have clicked the the mysql box in the build options.

thanks
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: SQL connection on Android SDK

Post by Mark »

Hi,

Are you trying to use a local database on the Android device or a database on a remote server? If locally, then you should probably use SQLite instead of MySQL. If remotely, there might be a problem with the use of sockets (just a hunch). A solution would depend on what you'll reply.

What happens if you use a newer version of Android?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Re: SQL connection on Android SDK

Post by d.m.holdawayGA2553 »

its on a remote server.

i followed a few of the business-academy lessons, and this one

http://lessons.runrev.com/s/lessons/m/4 ... l-database

and like i said it works a treat on iOS and my desktop..
on mouseUp
-- use a global variable to hold the connection ID so other scripts can use it
global gConnectionID

-- set up the connection parameters - edit these to suit your database
put "www.something.com" into tDatabaseAddress
put "something" into tDatabaseName
put "example" into tDatabaseUser
put "example" into tDatabasePassword

-- connect to the database
put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult

-- check if it worked and display an error message if it didn't
-- & set the connection ID global
if tResult is a number then
put tResult into gConnectionID
answer info "Connected to the database." & cr & "Connection ID = " & gConnectionID
else
put empty into gConnectionID
answer error "Unable to connect to the database:" & cr & tResult
end if
end mouseUp


does that help at all?
d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Re: SQL connection on Android SDK

Post by d.m.holdawayGA2553 »

i also used version 4.0
sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: SQL connection on Android SDK

Post by sturgis »

You might check your standalone settings and make sure you check mySql under the externals section of the android settings.
d.m.holdawayGA2553
Posts: 81
Joined: Mon Jan 09, 2012 4:48 pm

Re: SQL connection on Android SDK

Post by d.m.holdawayGA2553 »

yes i have already tired that.
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: SQL connection on Android SDK

Post by genie »

I had this problem also...

Built the app for iPhone and android.

Works perfectly on LiveCode IDE RUN mode, works well on my iPhone, but I can't make it work on Android. I don't have a slight idea why... :( I sure checked MySQL support on my standalone application settings.

Can somebody please advise?


Thanks,
Genie
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: SQL connection on Android SDK

Post by Klaus »

What is in "the result" after the connections fails?
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: SQL connection on Android SDK

Post by genie »

Klaus wrote:What is in "the result" after the connections fails?
It says:

Unknown MySQL server host 'www.***.com'(13)"
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: SQL connection on Android SDK

Post by Klaus »

Hi genie,
genie wrote:
Klaus wrote:What is in "the result" after the connections fails?
It says:Unknown MySQL server host 'www.***.com'(13)"
hmm, if that works on iOS and desktop then this is indeed very mysterious!
Sorry, no idea.


Best

Klaus
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: SQL connection on Android SDK

Post by genie »

Hi thread starter!

Kindly check you standalone application settings...

On the bottom right corner of the Android tab, there is "Application Permissions". Make sure you tick "Internet" in there. Doing this ensures that your adroid app can connect to your server via the Internet. :)

I got this advise from runrev. :) I tried and it worked on my end.


Regards,
Genie
Post Reply