So, I added MySQL Connector / J 5.1.16 to my Build Path project. I use the standard OSX Java package and MAMP Pro 1.9.4 with MySQL 5.1.44 and Eclipse.
I created a simple java application with the following function:
private static String dbUrl = "jdbc:mysql://127.0.0.1:3306/mpp"; private static String dbUsername = "root"; private static String dbPassword = "root"; private Statement statement = null; private void dbConnect() { try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword); statement = connection.createStatement(); } catch(SQLException e) { System.err.print(e.getMessage() + " ARGH!"); } catch(Exception e) { System.err.print(e.getMessage() + " FUUUUUUUUUU!"); } }
When I start, I get the following error:
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. ARGH!
I googled and searched for about an hour without success. Any ideas how to fix this? The JDBC driver should be good, I tested it.
EDIT
I tried to run this through the console
SnowCave:src stefanschipor$ java -cp $CLASSPATH test
I get the same result as above
source share