0

I'm trying to connect to a MySQL DB inside an Android Studio project and i keep getting an error that im denied access, i tried a normal Java program and it was fine but with Android it won't.

This is the error: java.sql.SQLException: Access denied for user 'root'@'Hadi.mynet' (using password: YES)

And this the code for connecting:

new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Class.forName("com.mysql.cj.jdbc.Driver");
                    con = DriverManager.getConnection("jdbc:mysql://192.168.1.108/menu","root","root");
                } catch (SQLException | ClassNotFoundException throwables) {
                    throwables.printStackTrace();
                }
            }
        }).start();

Thanks in advance.

Hadi
  • 1
  • 1
  • 1
    Please read: [JDBC vs Web Service for Android](https://stackoverflow.com/q/15853367/295004) – Morrison Chang Apr 09 '22 at 22:24
  • how can you access it directly without a password? An error is saying that `Access denied for user 'root'@'Hadi.mynet' (using password: YES)` means you have to add password also to access your database. – M DEV Apr 10 '22 at 11:07

0 Answers0