[英]java.sql.SQLException: Access denied for user 'root'@'192.148.2.106' (using password: YES) in Android
i'm trying to connect my android app to mysql database with JDBC, but i keep getting this exception when i test the app in a real device and i really can't figure it out i have tried to create a new user in XAMPP and granting all privileges to the user, but none of that worked out i'm trying to connect my android app to mysql database with JDBC, but i keep getting this exception when i test the app in a real device and i really can't figure it out i have tried to create a new user in XAMPP and授予用户所有权限,但没有一个成功
could somebody help me with that please, i'm really blocked?有人可以帮我吗,我真的被阻止了吗?
My activity code:我的活动代码:
public class SuccessActivity extends AppCompatActivity {
public static final String url="jdbc:mysql://192.148.2.114:3306/gtransport";
public static final String user="root";
public static final String pass="a123";
TextView EmailShow;
TextView Etat;
String EmailHolder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_success);
EmailShow = (TextView)findViewById(R.id.email_textview);
Etat=(TextView)findViewById(R.id.etat_textview);
Intent intent = getIntent();
EmailHolder = intent.getStringExtra(MainActivity.USER_NAME);
EmailShow.setText(EmailHolder);
new MyTask().execute();
}
private class MyTask extends AsyncTask<Void,Void,Void>{
private String V_etat="";
@Override
protected Void doInBackground(Void... voids) {
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con= DriverManager.getConnection(url,user,pass);
String sql="select * from Chauffeur where email=?";
PreparedStatement stmt=con.prepareStatement(sql);
stmt.setString(1,EmailHolder);
ResultSet rs=stmt.executeQuery();
while(rs.next()) {
V_etat = (rs.getString("nom"));
}
}
catch(Exception e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
Etat.setText(V_etat);
super.onPostExecute(aVoid);
}
}
}
i resolved my problem, i figured out that when i was creating the user i typed the password by myself.and at the same time i forgot and clicked on "generate password button" which generates an automatic password for u .我解决了我的问题,我发现当我创建用户时,我自己输入了密码。同时我忘记并点击了“生成密码按钮”,它会为你生成一个自动密码。
so anyone who is facing similar problem pay attention to that while creating a new user !所以任何面临类似问题的人在创建新用户时都要注意这一点!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.