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.
Please advise and let me know if you need further information.
2
Answers
It creating error because you have not passed username and password
Try this code it helps to connect Mysql using java
for more information use this : https://docs.oracle.com/javase/8/docs/api/java/sql/DriverManager.html
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.