diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2015-11-25 21:34:12 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2015-11-25 21:34:12 +0000 |
commit | 6deaa095c7c77dfebf797fe4e4e1ff086cf932d9 (patch) | |
tree | 002682c9c8b26ad8f666ea44cbd831f22bc0c8d0 /src | |
parent | 0d5f1566e0f22324d522ff8083bfd3a5020e3e9d (diff) | |
download | jackcess-6deaa095c7c77dfebf797fe4e4e1ff086cf932d9.tar.gz jackcess-6deaa095c7c77dfebf797fe4e4e1ff086cf932d9.zip |
Add FileFormat.GENERIC_JET4 in order to support getting the file format for jet4 databases with no AccessVersion property (e.g. those created programmatically using ADOX). fixes issue #129
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@970 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r-- | src/changes/changes.xml | 5 | ||||
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/Database.java | 9 | ||||
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java | 7 | ||||
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | src/test/data/V2007/complexDataTestV2007.accdb | bin | 524288 -> 524288 bytes | |||
-rw-r--r--[-rwxr-xr-x] | src/test/data/V2007/linkerTestV2007.accdb | bin | 454656 -> 454656 bytes | |||
-rw-r--r--[-rwxr-xr-x] | src/test/data/V2007/oldDatesV2007.accdb | bin | 483328 -> 483328 bytes | |||
-rw-r--r--[-rwxr-xr-x] | src/test/data/V2007/testOleV2007.accdb | bin | 8634368 -> 8634368 bytes | |||
-rw-r--r--[-rwxr-xr-x] | src/test/data/V2010/complexDataTestV2010.accdb | bin | 544768 -> 544768 bytes | |||
-rw-r--r-- | src/test/data/adox_jet4.mdb | bin | 0 -> 65536 bytes | |||
-rw-r--r--[-rwxr-xr-x] | src/test/data/linkeeTest.accdb | bin | 524288 -> 524288 bytes | |||
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java | 11 |
12 files changed, 33 insertions, 0 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2350392..c62159a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -9,6 +9,11 @@ Throw a prettier exception when maxing out the row size during row creation. </action> + <action dev="jahlborn" type="fix" system="SourceForge2" issue="129"> + Add FileFormat.GENERIC_JET4 in order to support getting the file + format for jet4 databases with no AccessVersion property (e.g. those + created programmatically using ADOX). + </action> <action dev="jahlborn" type="update" system="SourceForge2" issue="128"> Add some utility methods (DatabaseBuilder.createDateFormat and DatabaseBuilder.toCompatibleCalendar) for handling Dates in an Access diff --git a/src/main/java/com/healthmarketscience/jackcess/Database.java b/src/main/java/com/healthmarketscience/jackcess/Database.java index 1e6d6cf..48273ef 100644 --- a/src/main/java/com/healthmarketscience/jackcess/Database.java +++ b/src/main/java/com/healthmarketscience/jackcess/Database.java @@ -130,11 +130,20 @@ public interface Database extends Iterable<Table>, Closeable, Flushable */ public enum FileFormat { + /** A database which was created by MS Access 97 */ V1997(".mdb"), + /** A database which was most likely created programmatically (e.g. using + windows ADOX) */ + GENERIC_JET4(".mdb"), + /** A database which was created by MS Access 2000 */ V2000(".mdb"), + /** A database which was created by MS Access 2002/2003 */ V2003(".mdb"), + /** A database which was created by MS Access 2007 */ V2007(".accdb"), + /** A database which was created by MS Access 2010+ */ V2010(".accdb"), + /** A database which was created by MS Money */ MSISAM(".mny"); private final String _ext; diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java index 1984dc3..490e75f 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java @@ -110,6 +110,7 @@ public class DatabaseImpl implements Database static { addFileFormatDetails(FileFormat.V1997, null, JetFormat.VERSION_3); + addFileFormatDetails(FileFormat.GENERIC_JET4, null, JetFormat.VERSION_4); addFileFormatDetails(FileFormat.V2000, "empty", JetFormat.VERSION_4); addFileFormatDetails(FileFormat.V2003, "empty2003", JetFormat.VERSION_4); addFileFormatDetails(FileFormat.V2007, "empty2007", JetFormat.VERSION_12); @@ -202,6 +203,7 @@ public class DatabaseImpl implements Database /** Name of the system object that is the parent of all databases */ private static final String SYSTEM_OBJECT_NAME_DATABASES = "Databases"; /** Name of the system object that is the parent of all relationships */ + @SuppressWarnings("unused") private static final String SYSTEM_OBJECT_NAME_RELATIONSHIPS = "Relationships"; /** Name of the table that contains system access control entries */ @@ -739,6 +741,11 @@ public class DatabaseImpl implements Database // need to check the "AccessVersion" property String accessVersion = (String)getDatabaseProperties().getValue( PropertyMap.ACCESS_VERSION_PROP); + + if(isBlank(accessVersion)) { + // no access version, fall back to "generic" + accessVersion = null; + } _fileFormat = possibleFileFormats.get(accessVersion); diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java b/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java index 115dd94..eed8832 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/JetFormat.java @@ -127,6 +127,7 @@ public abstract class JetFormat { static { POSSIBLE_VERSION_4.put(ACCESS_VERSION_2000, Database.FileFormat.V2000); POSSIBLE_VERSION_4.put(ACCESS_VERSION_2003, Database.FileFormat.V2003); + POSSIBLE_VERSION_4.put(null, Database.FileFormat.GENERIC_JET4); } } diff --git a/src/test/data/V2007/complexDataTestV2007.accdb b/src/test/data/V2007/complexDataTestV2007.accdb Binary files differindex 3f9ff36..3f9ff36 100755..100644 --- a/src/test/data/V2007/complexDataTestV2007.accdb +++ b/src/test/data/V2007/complexDataTestV2007.accdb diff --git a/src/test/data/V2007/linkerTestV2007.accdb b/src/test/data/V2007/linkerTestV2007.accdb Binary files differindex 57c6b25..57c6b25 100755..100644 --- a/src/test/data/V2007/linkerTestV2007.accdb +++ b/src/test/data/V2007/linkerTestV2007.accdb diff --git a/src/test/data/V2007/oldDatesV2007.accdb b/src/test/data/V2007/oldDatesV2007.accdb Binary files differindex 0e96b91..0e96b91 100755..100644 --- a/src/test/data/V2007/oldDatesV2007.accdb +++ b/src/test/data/V2007/oldDatesV2007.accdb diff --git a/src/test/data/V2007/testOleV2007.accdb b/src/test/data/V2007/testOleV2007.accdb Binary files differindex 398818e..398818e 100755..100644 --- a/src/test/data/V2007/testOleV2007.accdb +++ b/src/test/data/V2007/testOleV2007.accdb diff --git a/src/test/data/V2010/complexDataTestV2010.accdb b/src/test/data/V2010/complexDataTestV2010.accdb Binary files differindex 7df4baa..7df4baa 100755..100644 --- a/src/test/data/V2010/complexDataTestV2010.accdb +++ b/src/test/data/V2010/complexDataTestV2010.accdb diff --git a/src/test/data/adox_jet4.mdb b/src/test/data/adox_jet4.mdb Binary files differnew file mode 100644 index 0000000..7fbdb1b --- /dev/null +++ b/src/test/data/adox_jet4.mdb diff --git a/src/test/data/linkeeTest.accdb b/src/test/data/linkeeTest.accdb Binary files differindex a159097..a159097 100755..100644 --- a/src/test/data/linkeeTest.accdb +++ b/src/test/data/linkeeTest.accdb diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java index e8a5287..93c5ca9 100644 --- a/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/impl/JetFormatTest.java @@ -242,6 +242,17 @@ public class JetFormatTest extends TestCase { } } } + + Database db = null; + try { + db = open(Database.FileFormat.GENERIC_JET4, + new File(DIR_TEST_DATA, "adox_jet4.mdb")); + assertEquals(Database.FileFormat.GENERIC_JET4, db.getFileFormat()); + } finally { + if(db != null) { + db.close(); + } + } } } |