How do I connect to MySQL database from my Java applications?

The JDBC (Java Database Connectivity) engine will take care of the communication between the database server and your Java applications. To access your database using JDBC, you will need the following code to initiate the database connection:
              
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost/loginname_dbname",
"username", "password");
} catch (Exception e) { ..... }

For more information on MySQL and JDBC, please refer to MM.MySQL.JDBC Resources.