I am trying to use JDBC to connect to a mysql database on our school's server. Here is my code:
try
{
// Step 1: Load the JDBC driver.
Class.forName("com.mysql.jdbc.Driver");
System.out.println(1);
// Step 2: Establish the connection to the database.
String url = "jdbc:mysql://csci.lakeforest.edu:3306/csci427_spring11";
System.out.println(2);
Connection conn = DriverManager.getConnection(url,"username","password");
System.out.println(3);
Statement stmt = conn.createStatement (); // Create statement
System.out.println(2);
}
catch (Exception e)
{
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
The 1 and 2 are printing, but then I get this error:
**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.**
Any help will be appreciated.
Thank you