Read-only access to DBISAM tables (.dat + .blb) from Kotlin/Java.
DbisamTable.open(Path.of("customers.dat")).use { table ->
for (row in table.rows()) {
println("${row.recordId}: ${row["Name"]}")
}
}Encrypted tables need the password: DbisamTable.open(path, password), or JDBISAM_PASSWORD for the CLI.
mvn install # library in the local Maven repo
mvn -q exec:java -Dexec.args="schema path/to/x.dat" # columns
mvn -q exec:java -Dexec.args="csv path/to/x.dat" # data as CSV| Column type | Kotlin value |
|---|---|
| STRING, FIXEDCHAR, GUID | String (Windows-1252, up to the first NUL) |
| DATE / TIME / TIMESTAMP | LocalDate / LocalTime / LocalDateTime |
| BOOLEAN | Boolean |
| SMALLINT / WORD, INTEGER, AUTOINC / LARGEINT | Short / Int / Long |
| FLOAT, CURRENCY | Double |
| BCD | BigDecimal |
| BYTES / VARBYTES | ByteArray: the full field / without trailing zero bytes |
| BLOB, MEMO, GRAPHIC | DbisamTable.Blob, read lazily with bytes() or text() |
null means the column's null flag is clear. DBISAM itself stores '' as null and trims trailing spaces.
Delphi's zero date 1899-12-30 is returned as is.
Errors: DbisamFormatException when a table cannot be read at all (empty, inconsistent, missing or wrong password),
DamagedBlobException for a single damaged blob; the rest of the table stays readable.
DBISAM keeps no change log. Use row.recordId as key and row.contentHash() to see whether a row changed;
the header's lastModified matches the file's modification time, so unchanged tables can be skipped.
Record ids survive optimize and repair, and a deleted row's id is not reused (its slot is).
The hash covers blob contents, since optimize moves blobs and a rewritten blob gets a new id.
All little-endian. What is listed here was checked against a real database; anything else is unknown.
Header (512 bytes): row count u32 @0x29, row size u16 @0x2D, column count u16 @0x2F,
last modified f64 @0x3F (days since 3798-12-28), description length u8 @0x47 + text @0x48,
user version u16 @0xC1 + u8 @0xC3, encrypted flag u8 @0xAC, password check 16 bytes @0xAD.
Columns: one 768-byte block per column from 0x200: number u16 @0 (from 1), name length u8 @2 + name @3,
type u16 @0xA4, declared length u16 @0xA6 (strings), offset in row u16 @0xAC.
Rows follow the column blocks: deleted flag @0, record id u32 @5, checksum 16 bytes @9, columns from 25.
Each column starts with a null-flag byte, then the value.
| Type code | Type | Bytes |
|---|---|---|
| 0x01 | string | declared length + 1 |
| 0x02 | date, days from 0001-01-01 (= 1) | 4 |
| 0x03 / 0x1603 / 0x1A03 | blob / memo / graphic | 8: first block u32, blob id u32 |
| 0x04 | boolean | 2 |
| 0x05 / 0x06 / 0x12 | 16 / 32 / 64-bit integer | 2 / 4 / 8 |
| 0x07 / 0x1507 | float / currency, IEEE double | 8 |
| 0x08 | BCD (Delphi TBcd: precision, sign + places, one digit per nibble) |
34 |
| 0x09 / 0x0F | bytes / varbytes, zero-padded, no length stored | declared length |
| 0x0A | time, ms since midnight | 4 |
| 0x0B | timestamp, ms since 0001-01-01 minus one day, as double | 8 |
| 0x0C | word, unsigned 16-bit | 2 |
| 0x1D06 | autoinc | 4 |
| 0x1F01 / 0x3201 | fixed char / GUID as text | declared length + 1 |
Encryption: Blowfish-CBC with a zero IV, key = MD5 of the password (Windows-1252). The header itself is not encrypted. The column blocks together form one CBC stream, each row is its own stream, and so is each .blb block; encrypted tables have row sizes that are a multiple of 8. The password check is the key encrypted with itself.
Blobs (.blb): 512-byte blocks, block 0 is a header. Each block: previous u32 @0, next u32 @4 (0 = last),
bytes used u16 @8, data from 18. The first block of a blob also has its id u32 @10 and total size u32 @14. A shrunk blob keeps its old chain,
so reading stops at the total size.
- VARBYTES ending in zero bytes lose them: DBISAM stores no length, neither in the row nor in the
.idx. - Only checked against DBISAM 4.52.
- Text is always read as Windows-1252; other locales are untested.
mvn verify runs tests on generated tables and on tables made with DBISAM 4.52 from made-up data
(src/test/resources/dbisam, with notes on what went in). JDBISAM_TESTDATA=<dir> mvn test also reads every .dat under <dir>
and checks invariants without printing any data; set JDBISAM_PASSWORD to include encrypted tables. Keep real databases out of the repo; testdata-private/ is ignored.