String Url="jdbc:mysql://" + /* IP or domain database server */ +"/" + /*database */; //It is important to encapsulate the connection in "try", which may cause errors. try { BD_Conexion = DriverManager.getConnection(Url, /* user */, /* password*/); }catch(SQLException SQLError){ //Make sure there are no errors in the connection. }