I trying to conncet to my MySQL Database hosted in a virtual machine, but it doesn’t work
for me.
Here is my setup:
- Newest Ubuntu Server witch Apache2 mysql installed and is working
- Database “feedback” with the table “test” set up and filled with test data
- The network adapter is bridged. The IP of the server is (if I type in ifconfig) 10.0.0.1 and the IP of my pc is 10.0.0.4.
- Port 3306 was manually opened. The jar mysql connector java 5.1.21-bin.jar is a Referenced Libary
Here is the Java Code:
import java.sql.*;
public class Main {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("Sucess");
Connection con = DriverManager.getConnection("jdbc:mysql://10.0.0.1/feedback","root","myrootpassword");
con.setReadOnly(true);
} catch (Exception e) {
System.err.print("NO CONNECTION");
}
}
}
I hope that someone could help with this, because I’m working on this problem for a while.
Thanks
Just two ideas:
Hope this helps !