Android Tutorial Connect Android to MySQL Database Tutorial

Discussion in 'Tutorials & Examples' started by Erel, Mar 21, 2011.

  1. Erel

    Erel Administrator Staff Member Licensed User

    The file can only be used with the full version as it requires additional libraries. Only licensed users can download it.
  2. GR88sa

    GR88sa New Member Licensed User

    Insert Query - Not possible

    Error: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused, StatusCode: -1

    This is the error apears when i try run this project on local area network, using Wamp and android emulator.

    I'm new on Basic4Android

    Help me please! :sign0163:
  3. sigster

    sigster Active Member Licensed User


    I try this code
    I can run it but I don't get country list

    this popup maybe 1 sec and diapers then nothing
    ProgressDialogShow("Fetching list of countries")

    I am using remote server not localhost

  4. TomDuncan

    TomDuncan Active Member Licensed User

    Instead of localhost put in the pcpip addesss of your server. Works for me.
  5. sigster

    sigster Active Member Licensed User

    Know it work I did not change anything ? chance the path into wront path and then back and it work ! ??

    but I have problem with characters like ð,æ if name have this characters
    then I get NULL in Listview

  6. sigster

    sigster Active Member Licensed User

    Finish to fix this
    know I nont get NULL if characters is ð,æ

    -->>> mysql_query("SET NAMES 'UTF8'");

    $query = file_get_contents("php://input");
    $sth = mysql_query($query);

  7. Arbel

    Arbel New Member Licensed User

    Why can't I read my data!!

    Hi All,

    I just follow MySQL sample code but pointing our database and no errors, everything looks ok but no data is returned on the response function.
    I can execute the php part on my server and the result is exactly as expected
    [{"name":"Peter, Sellers", "id":"......
    but nothing on the res = Response.GetString("UTF8"). Wired!!!

    Any ideas at all???
    I'm just desperate!
  8. Erel

    Erel Administrator Staff Member Licensed User

    What is printed from this line:
    Log("Response from server: " & res)
  9. jegadk

    jegadk Member Licensed User

    Any chance to get the exact same sample, just with an asp script.

    Have this code to work in my asp

    response.write QueryToJSON(myConn, "SELECT name,id FROM countries ORDER BY id").flush


    response.write QueryToJSON(myConn, request.querystring).flush

    fails, because i can't read anything in the querystring. Debugging shows that Query.GetBytes("UTF8") says "SELECT name,if FROM countries...."

  10. Erel

    Erel Administrator Staff Member Licensed User

    Have you seen the MS SQL example? It uses ASP .Net. Maybe it will be easier to convert.
  11. jegadk

    jegadk Member Licensed User

  12. naq219

    naq219 New Member

    whhuy? a can't download attach:BangHead:
  13. Erel

    Erel Administrator Staff Member Licensed User

    This file is only available to licensed users.
  14. isk2837

    isk2837 Member Licensed User

    Trying to make an app that connects to a database, but the log keeps containing this error - Error: java.lang.IllegalArgumentException: Host name may not be null, StatusCode: -1

    What does this mean exactly? I'm still completely new to this program, so can someone explain to me what it could mean is wrong?
  15. Erel

    Erel Administrator Staff Member Licensed User

    Have you included "http://" in the Url?
  16. isk2837

    isk2837 Member Licensed User

  17. Erel

    Erel Administrator Staff Member Licensed User

    See my answer in the new thread you started.
  18. guidoarfini

    guidoarfini Member Licensed User

    mysql to bitmap

    Hello, I had previously built the database (sqlite) and I used cursor1.getblob, now I have moved all from mysql server with php, but how do I transfer the photos because I like Null response from mysql? If I find as I look at mysql BLOB Binary Data

    Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
    Msgbox("server Connect!","")

    Dim IDArtista,Cognome,Nome,Pseudo,Nazionalita,TipoArtista,DataNascita,FotoArtista As String

    Dim res As String
    res = Response.GetString("UTF8")
    Log("Response from server: " & res)
    Dim parser As JSONParser
    Select TaskId
    Case Artiste_list
    Dim VerfArtista As List
    VerfArtista = parser.NextArray
    For I = 0 To VerfArtista.Size -1
    Dim M As Map
    Dim InputStream1 As InputStream
    Dim Buffer() As Byte
    Dim Bitmap1 As Bitmap

    M = VerfArtista.Get(I)
    DataNascita =M.Get("DataNascita")

    Buffer = M.Get("FotoArtista")
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)


  19. Erel

    Erel Administrator Staff Member Licensed User

    The response from the server returns as string. You will need to convert the bytes array to base64 string in the PHP script.
  20. guidoarfini

    guidoarfini Member Licensed User

    I do not know php, for this experiment I used your php code, you can post some sample code?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice