base url

rslzwgfq  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(331)

我有一个android应用程序连接到我的数据库的问题。我写的代码正确吗?或者我需要设置一个web主机,而不是运行localhost服务器?

public static String BASE_URL = "http://localhost/jobportal/api";

代码:

public interface Consts {
public static String JOB_PORTAL = "JobPortal";

public static String BASE_URL = "http://localhost:8080/jobportal/api";
public static String IS_REGISTER_SEEKER = "is_register_seeker";
public static String IS_REGISTER_RECRUITER = "is_register_recruiter";

/*API DETAILS*/
public static String POST_METHOD = "POST";
public static String SIGNUP_API_SEEKER = "register-new-seeker";
public static String SIGNUP_API_RECRUITER = "register-new-recruiter";
public static String LOGIN_API_SEEKER = "login-seeker";
public static String LOGIN_API_RECRUITER = "recruiter-login";
public static String ACTIVE_JOBS_API = "search-job";
public static String APPLY_JOB_API = "apply-on-job";
public static String POST_JOB_API = "post-job";
public static String GENERAL = "general ";
public static String FILL_SEEKER_PROFILE = "fill-seeker-profile";
public static String FILL_RECRUITER_PROFILE = "fill-recruiter-profile";
public static String SEEKER_CHANGE_PASSWORD = "seeker-change-password ";
public static String RECRUITER_CHANGE_PASSWORD = "recruiter-change-password ";
public static String FORGOT_PASSWORD = "forgot-password ";
public static String GET_RECRUITER_JOBS = "get-recruiter-jobs";
public static String JOB_APPLICATION = "job-application";
public static String DELETE_JOB = "delete-job";
public static String SEEKER_PROFILE_DETAIL_ON_JOB = "seeker-profile-detail-on-job";
public static String GET_RECRUITER_JOB_DETAIL = "get-recruiter-job-detail";

截图取自ide
这是我的数据库

4bbkushb

4bbkushb1#

您的url似乎缺少数据库的端口。使用端口#检查url并尝试使用它进行连接

3okqufwl

3okqufwl2#

首先,你不应该把变量放在接口类里面。相反,您可以创建一个简单的类,如

public class Consts {
   public static final String JOB_PORTAL = "JobPortal";
   ....
   //etc
}

第二,我建议您使用改装连接您的手机到数据库。请阅读此处的文档

相关问题