1 year ago

#375629

test-img

Fernas Techno

How can I access the database remotely using java wihtout added the IP in Remote MySQL

I have hosting on HostGator and I create database, but I can't to access to this database from any network before (Go to "cPanel" -> "Remote MySQL" and Add Access Host(IP Address))

enter image description here

How I can allow to any IP access to my database from my java program

     try {

        Class.forName("com.mysql.jdbc.Driver");

        Connection con = DriverManager.getConnection("jdbc:mysql://ns0000.hostgator.com:3306/employee101", "admin", "passAdmin");

        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT username FROM employee_data");

        while (rs.next()) {
            System.out.println(rs.getString(1));
        }

        con.close();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

Knowing that the code works without problems if the IP is added to Remote MySQL, and if I do not add the IP, the following error will appear to me:

Access denied for user 'admin'@'188.247.79.199' (using password: YES)

java

mysql

jdbc

remote-access

0 Answers

Your Answer

Accepted video resources