MySQL on Android

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

MySQL on Android

Post by Jamie37 » Fri Dec 25, 2015 6:15 pm

Hello,

I have got the code below which connects to MySQL database and checks for a username and password. However it works on windows fine but when I use it on an android device I get the error 'Cant connect to TCP/IP socket (13)'. I dont really kinow why its saying this and I have checked the tick box for MySQL in the stand alone application settings. Its only a local database for a college prohjec tim doing so does not need to be too complicated.

Hopefully somebody can help. Below is the code

Code: Select all

on loginCheck
   -- 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 "address" into tDatabaseAddress
    put "applogininfo" into tDatabaseName
    put "user" into tDatabaseUser
    put pass" 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
    else
        put empty into gConnectionID
        answer error "Unable to connect to the database:" & cr & tResult
     end if
     
     //SELECTS USER DATA FROM DATABASE AND PUTS THEM INTO VARIABLES 'theUserData & thePassData'
     
     put "SELECT Username FROM userpass" into theUser
     put revDataFromQuery(,,gConnectionID,theUser) into theUserData
     put "SELECT Password FROM userpass" into thePass
     put revDataFromQuery(,,gConnectionID,thePass) into thePassData
      
      //CHECKS TO SEE IF THE INPUTS MATCH THE DATABASE RECORDS
   
     if theUserData = the text of field "username" and thePassData = the text of field "password"  then
     go to card accessed
      else
         answer "Incorrect username or password. Please try again."
         exit to top
         end if
end loginCheck
Thanks
Jamie

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: MySQL on Android

Post by ClipArtGuy » Fri Dec 25, 2015 6:30 pm

Have you also checked the "internet" option in android standalone settings? Also try putting "MySQL" as "mysql", I think it may need to be lower case.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: MySQL on Android

Post by Klaus » Sat Dec 26, 2015 12:59 pm

ClipArtGuy wrote:Also try putting "MySQL" as "mysql", I think it may need to be lower case.
Yep, since iOS and Android have a case-sensitive OS, this is mandatory!
Haven't we been there before, Jamie? 8)

Post Reply

Return to “Databases”