jueves, 26 de noviembre de 2015

Bases de Datos MySQL

http://www.1keydata.com/es/sql/sql-select.php

Ejercicios de bases de datos:
http://www.jorgesanchez.net/bd/ejercicioser.html

3 comentarios:

  1. public String leer(){
    CloseableHttpClient cliente = HttpClients.createDefault();
    HttpContext contexto = new BasicHttpContext();
    HttpPost httpget = new HttpPost("http://quintoc.esy.es/connect/login1.php/");
    String resultado=null;

    try {
    HttpResponse response = cliente.execute(httpget, contexto);
    HttpEntity entity = response.getEntity();
    resultado = EntityUtils.toString(entity, "UTF-8");
    //cliente.close();
    } catch (Exception e) {
    // TODO: handle exception

    new AlertDialog.Builder(this)
    .setTitle("Error: leer()")
    .setMessage("" + e)
    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface arg0, int arg1) {
    // Some stuff to do when ok got clicked
    }
    })
    .show();
    }
    return resultado;
    }

    public void marcar(String response)
    {
    try {
    JSONArray json= new JSONArray(response);
    PolylineOptions options = new PolylineOptions().width(5).color(Color.BLUE).geodesic(true);
    LatLng point;

    for(int i = 0; i<json.length(); i++)
    {
    point = new LatLng(json.getJSONObject(i).getDouble("lat"),json.getJSONObject(i).getDouble("long"));
    arrayPoints.add(point);
    }

    options.addAll(arrayPoints);
    mMap.addPolyline(options);

    } catch (Exception e) {
    // TODO: handle exception

    new AlertDialog.Builder(this)
    .setTitle("Error: JSON")
    .setMessage("" + e)
    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface arg0, int arg1) {
    // Some stuff to do when ok got clicked
    }
    })
    .show();
    }
    }







    Son los métodos que utilicé para leer la base de datos y para marcar la ruta en el mapa. Y ésta es la librería que se tiene que agregar al graddle:

    compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'

    ResponderEliminar
    Respuestas
    1. Este comentario ha sido eliminado por el autor.

      Eliminar
    2. Le puse AlertDialog para mostrar los errores porque el toast se quitaba luego luego y no me dejaba leer el error hahaha

      Y ps solo recordar importar (Alt + Enter) las librerias al código en base a la del graddle, son las que dicen cz...

      Eliminar