public static void main (String[] args) {
String host = "jdbc:mysql://[email protected]:3306/";
String uname = "root";
String db = "customers";
String password = "somepassword";
String driver = "com.mysql.jdbc.Driver";
int i = 0;
try {
Class.forName(driver).newInstance();
Connection conn = DriverManager.getConnection(host+db, uname, password);
Statement st = conn.createStatement();
i = st.executeUpdate("INSERT INTO users " +
"VALUES ('Simpson1', '[email protected]', 'Springfield')");
if(i==1)
System.out.println("Sucessfully Updated table");
conn.close();
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
}
I am trying to connect to an AWS DB, but I am getting the following exception and error while I run the program above:
Got an exception! 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.
Is it error in the hostname I am trying to connect to?