0

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

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
kgromeo
  • 3
  • 1

1 Answers1

1

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"));
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
  • I tried absolute path, but i get following error Default constructor cannot handle exception type IOException thrown by implicit super constructor. Must define an explicit constructor – kgromeo Mar 11 '17 at 01:35
  • The `DatabaseBuilder.open` method might throw an `IOException` so you need to handle it. Either `catch` it or add a `throws` clause to your own method definition. – Gord Thompson Mar 11 '17 at 02:33