0

I have a MYSQL web server that I'm using for an app and I can't seem to connect to it through Java. I have the .jar file added and everything, my password is stored on my pc the day I created it and my username is correct as well. I'm getting an exception saying it cannot create a connection to the Database server. Any idea why I would get this error

FYI - Changed the password and name for security reasons

    try{
            Class.forName("com.mysql.jdbc.Driver");
            connect = DriverManager.getConnection("jdbc:mysql://xxxxxxx:3306/kospotco_DoIT", "user", "pass");

            Statement statement = connect.createStatement();
            ResultSet result = statement.executeQuery("SELECT * FROM users");

            while (result.next()){
                Toast.makeText(this, result.getString(0) + result.getString(1), Toast.LENGTH_SHORT).show();
            }

        } catch (ClassNotFoundException | SQLException x) {
            Toast.makeText(this, x.toString(), Toast.LENGTH_SHORT).show();
            x.printStackTrace();
        }      
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:828)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at java.sql.DriverManager.getConnection(DriverManager.java:569)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at java.sql.DriverManager.getConnection(DriverManager.java:219)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.taskit.Login.onClick(Login.java:31)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at android.view.View.performClick(View.java:6597)
2021-09-16 20:49:54.421 18845-18845/com.taskit W/System.err:     at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at android.view.View.performClickInternal(View.java:6574)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at android.view.View.access$3100(View.java:778)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at android.view.View$PerformClick.run(View.java:25885)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at android.os.Handler.handleCallback(Handler.java:873)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at android.os.Looper.loop(Looper.java:193)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6669)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
2021-09-16 20:49:54.422 18845-18845/com.taskit W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err: Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at java.lang.reflect.Constructor.newInstance0(Native Method)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.NativeSession.connect(NativeSession.java:119)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:948)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:     at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:818)
2021-09-16 20:49:54.423 18845-18845/com.taskit W/System.err:    ... 20 more
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err: Caused by: java.net.SocketException: socket failed: EACCES (Permission denied)
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err:     at java.net.Socket.createImpl(Socket.java:492)
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err:     at java.net.Socket.getImpl(Socket.java:552)
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err:     at java.net.Socket.setTcpNoDelay(Socket.java:1012)
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err:     at com.mysql.cj.protocol.StandardSocketFactory.configureSocket(StandardSocketFactory.java:95)
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err:     at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:148)
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err:     at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63)
2021-09-16 20:49:54.424 18845-18845/com.taskit W/System.err:    ... 23 more

0 Answers0