Ok so what i want to be able to do is connect to a mysql database. Here's my code so far:
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "postgresql-8.4-701.jdbc4.jar"; // MySQL MM JDBC driver
Class.forName(driverName);
// Create a connection to the database
String serverName = "mysql10.000webhost.com";
String mydatabase = "a2362883_test";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "a2362883_admin";
String password = "test";
connection = (Connection) DriverManager.getConnection(url, username, password);
System.out.println("Connected");
}
catch (ClassNotFoundException e) {
System.out.println("Could not find the database driver");
} catch (SQLException e) {
System.out.println("Could not connect to the database");
}
The problem is though that it keeps saying it could not find the database driver, even though i put postgresql-8.4-701.jdbc4.jar in the project file. So therefore it should find it, or is this not the driver? Im using java 1.6, snow leopard os and eclipse. By the way, the password isnt test but im not going to tell you it :P
Thanks,
jakx12.