Exception: No suitable drivers found for jdbc: mysql


I am trying to connect to a mysql database by using this simple code.

import java.sql.*;
public class OdbcAccessConnection_1 {
  public static void main(String [] args) {
    Connection con = null;
    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
    // Connect with a url string
      con = DriverManager.getConnection("jdbc:mysql://localhost/books","root","1234");
      System.out.println("Connection ok.");
    } catch (Exception e) {
      System.err.println("Exception: "+e.getMessage());

All it does is tell me if the connection is working. There is no problem with my database and this code/connection work on netbeans. The StackTrace i am getting is -

the java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/books
        at java.sql.DriverManager.getConnection(DriverManager.java:602)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at OdbcAccessConnection_1.main(OdbcAccessConnection_1.java:13)

I am working on 64 bit windows 7 and using 5.1 versions of the Connector/ODBC driver 64 bit. On the ODBC all seems to connect and the test was successful. But when i run the code i get the stack trace above. I am missing something very simple so any input and help would be very much appreciated. Thank you:)

Go to Run menu in netbeans or whatever IDE you are using =>Set Project Configuration then Customize.Then choose the Libraries on left dropdown menu Add your appropriate driver file either jar or folder. Click OK.