Documentation states a file will be opened in read-only if it is not writeable, but this is not the case if the JetFormat is read-only. The DatabaseImpl.open(...) method only checks for file permissions, resulting in an IOException at line 387.
Tested on version 2.1.4 (latest on maven).
I'm not sure i understand the bug? if the file is read only, it will automatically be opened read-only. otherwise, it will honor the read-only option parameter passed to the open method call.
for database formats for which jackcess does not support writing, the caller should set the read-only flag. if you don't set this flag, then you are indicating to jackcess that you intend on writing to the file (which is why jackcess then throws an exception).
Then maybe I misunderstood the documentation. In my case, I did not know which version of Access files I would be working with. So I read the documentation stating that any non-writable files will be opened as read-only, that seems good. But when I run the code, I get an IOException stating that the file is read-only. That seemed like a mistake in the documentation to me.
I admit it's a minor thing that is easily fixed when looking at the details of the open function, but that shouldn't be needed in my oppinion.
So, your expectation is that if you open a old format file, that it would automatically become read-only, and then you would subsequently get an exception if you attempted to write to the file?
Yes, that is how I would intrepret the current documentation.
On 1 October 2016 at 02:45, James Ahlborn jahlborn@users.sf.net wrote:
Ticket moved from /p/jackcess/bugs/137/
I tweaked the title and turned this into a feature request. since people seem to continue to stumble over this, i've changed the behavior so it automatically switches to read-only mode in this situation.
fixed in trunk, will be in the 2.1.6 release.