skip to Main Content

When I have set up a local Xmapp server using port forwarding and I am able to access outside the local network with the public IP address. However I always have to put "http://ip-address:port/phpmyadmin", but I just want to put "ip-address:port" to get to phpmyadmin. Is this possible? Is there another direction I should take?

The reason for this is because when I use java on Eclipse to access the database it doesn’t recognize "ip-address:port". Nor "jdbc:mysql://192.168.1.156:2000/phpmyadmin". When I look in another example it works using "jdbc:mysql://192.168.1.156:2000".

So I’m thinking because I get 403 forbidden when using 192.168.1.156:2000 when trying to access phpmyadmin; it won’t connect to the database.

enter image description here

Please advise and let me know if you need further information.

2

Answers


  1. It creating error because you have not passed username and password

    Try this code it helps to connect Mysql using java

    try {
                Class.forName("com.mysql.jdbc.Driver");
                con=DriverManager.getConnection("jdbc:mysql://localhost:3306/databse_name","username","password");
                
            
                
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    

    for more information use this : https://docs.oracle.com/javase/8/docs/api/java/sql/DriverManager.html

    Login or Signup to reply.
  2. As @MarkRotteveel points out, your second paragraph reveals that what you’re trying to do isn’t going to work.

    Your Java application is looking for a JDBC connector to the database directly. PhpMyAdmin is a graphical application meant to allow administrators to manage a database installation; it doesn’t provide any kind of connector or API for your Java application to connect through. You’ll need to provide the information of the database server directly instead. The default port for this is 3306 (whereas your web browser connection to phpMyAdmin is usually over port 443 or 80).

    Use the connection information to connect directly to the database instance and you should see much more success. If you’re trying to connect from outside your network, there are possible security concerns with exposing the database server directly to the internet, so you may instead want to write your own API that interacts with the database directly and instead expose the API directly to the internet for your application to access (your application would then use the API calls instead of directly accessing the database). That design decision is a little beyond the scope of what we’re able to answer here, but is a good thing to consider.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search