I have a java program connecting to a mdb database file. In Eclipse it works fine. Now I export the program as an jar file. When I start the program now and want to have access to the same file, I get the message
Data source name not found and no default driver specified.
I have already registered the database as ODBC-source in windows, but it doesn't work. The Path to the Database is the same in Eclipse and in jar. Maybe is the problem accessing some external source from within a jar?? Any suggestions?
protected static Connection getAccessConnection(String fullPath)
throws ClassNotFoundException, SQLException
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String url = "jdbc:odbc:Driver="
+ "{Microsoft Access Driver (*.mdb)};"
+ "DBQ="
+ fullPath.replace("\\", "/");
String username = "";
String password = "";
Connection result =
DriverManager.getConnection(url, username, password);
return result;
}