Conexion MySQL

Conexion MySQL

Estimados integrantes del Foro,

Cual es la mejor manera de extraer y añadir datos a una base de datos en MySQL cdesde una aplicacion movil,   Y si tienen un ejemplo básico de el modo de hacerlo. Gracias.

 

 

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

This is a basic example that i use in one of my Android apps using JDBC, download from: http://dev.mysql.com/downloads/connector/j

Connection connMySQL;  

public void connectMySQL (String user, String password,  String ip, String port, String catalog)  {
            if (connMySQL == null)    {
            String urlconnMySQL = "";
            if (catalog != ""){
                urlconnMySQL = "jdbc:mysql://" + ip + ":" +    Port + "/" + catalog;
            }else{
                urlconnMySQL = "jdbc:mysql://" + ip + ":" + port;
            }  
            if (user != "" & password != "" & ip != "" & Port != "") {
                try  {
                Class.forName("com.mysql.jdbc.Driver");
                    connMySQL = DriverManager.getConnection(urlconnMySQL, user, password);                    
                } 
                catch (ClassNotFoundException e) {
                      Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                } 
                catch (SQLException sqle) {
                    Toast.makeText(getApplicationContext(), sqle.getMessage(),  Toast.LENGTH_SHORT).show();
            }
            }
        }
    }

taken from this nice article:
http://www.ajpdsoft.com/modules.php?traducir=es-en&name=News&file=articl...

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today