0

I have tried a lot for JDBC using mysql but none of them work....
Can anyone help me how to get this work....

import java.sql.Connection;
import java.sql.DriverManager;

public class Main {
  public static void main(String[] argv) throws Exception {
    String driver = "com.mysql.jdbc.Driver";
    String connection = "jdbc:mysql://localhost:3306/abc";
    String user = "root";
    String password = "password";
    Class.forName(driver);
    Connection con = DriverManager.getConnection(connection, user, password);
    if (!con.isClosed()) {
      con.close();
    }
  }
}

I have downloaded com.mysql.jdbc.driver file.
included in my classpath but still i am getting the classnotfound error for "com.mysql.jdbc.Driver'.

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by IIM
1

Then you have not "included it on your classpath" properly. How did you "include it on your classpath" and how, exactly are you executing this code.

Edited by masijade: n/a

0

I already came with solution....
Their was nothing wrong.....only a bit mistake in the way of using classpath....
By the way thanks for your suggeestions!!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.