I know this is not a J2EE question, but I could not find an appropriate forum. The code is:
public static void main(String[] args) {
try {
DataSource dataSource = new AccessDataSource(
"D:\MyWorkspaces\Eclipse\The Paperless Office\PaperlessOffice.database",
1);
Connection conn = dataSource.getConnection();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Connection getConnection() throws SQLException {
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String fullConnectionString = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="
+ filePath;
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(fullConnectionString, userName,
password);
} catch (ClassNotFoundException cnfe) {
throw new SQLException("ClassNotFoundException");
} catch (SQLException e) {
throw new SQLException("SQLException");
}
I have in both the same Java compliance, 1.6, and the same jre “C:\Program Files (x86)\Java\jdk1.6.0_20”.