Java help

Hey all I am having problems opening an access db from java. Here is my code, errors at the bottom.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.sql.*;

public class Employees {
    public static Connection connect() {
	Connection db=null;
	try {
	    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	    db = DriverManager.getConnection("jdbc::odbc:Driver={Microsoft Access Driver (*.mdb, *accdb)}; DBQ=C:\\Users\\user\\Documents\\NetBeansProjects\\IT Assignment\\Employees.mdb");
	} catch(Exception e) {
	    System.err.println(e.getClass().getName()+": "+e.getMessage());
	}
	return(db);
    }
}

java.sql.SQLException: No suitable driver found for jdbc::odbc:Driver={Microsoft Access Driver (*.mdb, *accdb)}; DBQ=C:\Users\user\Documents\NetBeansProjects\IT Assignment\Employees.mdb
Have you added the jar that contains the driver to the class path?
Thank you for your help naraku. I have found the error and corrected it.

Corrected Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.sql.*;

public class Employees {
    public static Connection connect() {
	Connection db=null;
	try {
	    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	    db = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}; DBQ=EMPLOYEES.mdb;","", "");
	} catch(Exception e) {
	    System.err.println(e.getClass().getName()+": "+e.getMessage());
	}
	return(db);
    }
}
Topic archived. No new replies allowed.