Search code examples
javajackcess

jackcess - database pathname in databasebuilder.open


I have a Microsoft Access database called perso.accdb. I use the Jackcess library to try to open it using the following code taken from official documentation here

Database db = DatabaseBuilder.open(new File("mydb.mdb")); Sounds simple enough, but where exactly do I place my "perso.accdb"?! else how to write an absolute pathname?

thanks in advance


Solution

  • The file location is the string argument to the File object constructor. For a path relative to the current OS working directory in effect when your application runs you can use

    Database db = DatabaseBuilder.open(new File("datafiles/perso.accdb"));
    

    For an absolute path you can use something like

    Database db = DatabaseBuilder.open(new File("C:/path/to/perso.accdb"));