I have been having a problem with my Java application for a while now. I have tried several options in trying to figure out what is wrong from new drivers to registering the driver to changing permissions on my MySQL database. I only get this problem when I connect with an external IP. I think it might have something to do with IPV6 but I have attempted to disable that on my raspberry pi but when I run "netstat -tlnp" I get this:
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 547/java
tcp 0 0 0.0.0.0:8200 0.0.0.0:* LISTEN 547/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 547/java
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::5900 :::* LISTEN -
tcp6 0 0 :::8080 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN
This shows that MySQL server is still running off of tcp6 the port is 8080 I changed it from the standard 3600. My java main class looks like this: `public static String IP; //NULL Variables for the MySQL server IP public static final String user = "user"; //Username for the mySQL sever public static final String password = "pass"; //Password for the mySQL server TODO figure out how to hide password static Connection conn; //NULL connection to get connected to the mySQL server public static Scanner console = new Scanner(System.in); //Used to get numbers and strings from console
/**
* Runs the program
* @param args
*/
public static void main(String[] args) {
System.out.print("Internal or External IP (1 for Internal or 2 for external): ");
int choice = console.nextInt();
switch (choice){
case 1:
IP = "10.0.0.183";
break;
case 2:
IP = "external ipv4 address";
break;
}
//TRY CATCH method to ensure that the mySQL connection was successful
try{
conn = DriverManager.getConnection("jdbc:mysql://"+IP+":8080/mydb",user,password);
}catch(SQLException e){
System.out.println(e.getLocalizedMessage());
System.exit(1);
}`
This is the error I get when I try to connect to my external IPV4 address `Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.`
Does anyone have a solution or need anything else from me to help solve this problem! Thanks!