Mysql
 sql >> Database >  >> RDS >> Mysql

È possibile connettere la mia app Android al database mysql senza PHP.?

Yes, You can.

Devi aggiungere una libreria jar per mysql. Quindi codice java che si collegherà al server mysql.

import java.sql.DriverManager;

import android.database.SQLException;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.ResultSet;
import com.mysql.jdbc.Statement;


    public class SQLConnection {
        public static Connection conn = null;
        static void setConnection(String user,String pass,String urlServer,String dBase){   


              try
              {
                  String userName = user;
                  String password = pass;
                  String url = "jdbc:mysql://"+urlServer+"/"+dBase;

                  Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                  conn = DriverManager.getConnection (url, userName, password);
                  System.out.println ("Database connection established");
              }
              catch (Exception e)
              {
                  System.err.println (e.getMessage());
              }
              finally
              {
              }


        }
        public static Connection getConnection(){
        return conn;
        }

    }