i'm trying to connect to a remote mysql database (hosted on my website) through a standalone java app, havent found any tutorials on it yet but i've found some sample codes that i havent been able to get to work:
any ideas, tutorials or working code samples out there?
Code:
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
// Create a connection to the database
String serverName = "localhost";
String mydatabase = "mydatabase";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "username";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// Could not find the database driver
} catch (SQLException e) {
// Could not connect to the database
}
any ideas, tutorials or working code samples out there?