B4J Question Using DBF code from post - [DBF] Read/Write DBF file using jDBF

Kris.D

Member
I'm new here. Trying to use code posted by aeric in this post.


works fine with his dbf file and even some of my other dbf files but runing into error with few other of my own files.


Error:
Waiting for debugger to connect...
Program started.
Error occurred on line: 27 (Main)
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:91)
    at b4j.example.main._readdbf(main.java:101)
    at b4j.example.main._appstart(main.java:59)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.main(main.java:29)
Caused by: com.hexiong.jdbf.JDBFException: The field type is not a valid. Got: 0
    at com.hexiong.jdbf.JDBField.<init>(JDBField.java:47)
    at com.hexiong.jdbf.DBFReader.readFieldHeader(DBFReader.java:176)
    at com.hexiong.jdbf.DBFReader.init(DBFReader.java:58)
    at com.hexiong.jdbf.DBFReader.<init>(DBFReader.java:28)
    ... 22 more
Program terminated (StartMessageLoop was not called).

Looks like there is field that code doesn't like it but my table is simple. This is from DBF viewer.
Is there better way for me to debug this?

Thank you.

FieldTypeField SizeDecimal
COMPANY_IDC
8​
0​
PRICE_Y1C
9​
0​
PRICE_Y2C
9​
0​
PRICE_Y3C
9​
0​
PRICE_Y4C
9​
0​
PRICE_Y5C
9​
0​
PRICE_Y6C
9​
0​
PRICE_Y7C
9​
0​
PRICEH_Y1C
9​
0​
PRICEH_Y2C
9​
0​
PRICEH_Y3C
9​
0​
PRICEH_Y4C
9​
0​
PRICEH_Y5C
9​
0​
PRICEH_Y6C
9​
0​
PRICEH_Y7C
9​
0​
PRICEL_Y1C
9​
0​
PRICEL_Y2C
9​
0​
PRICEL_Y3C
9​
0​
PRICEL_Y4C
9​
0​
PRICEL_Y5C
9​
0​
PRICEL_Y6C
9​
0​
PRICEL_Y7C
9​
0​
PRICEO_Y1C
9​
0​
PRICEO_Y2C
9​
0​
PRICEO_Y3C
9​
0​
PRICEO_Y4C
9​
0​
PRICEO_Y5C
9​
0​
PRICEO_Y6C
9​
0​
PRICEO_Y7C
9​
0​
PRICEV_Y1C
13​
0​
PRICEV_Y2C
13​
0​
PRICEV_Y3C
13​
0​
PRICEV_Y4C
13​
0​
PRICEV_Y5C
13​
0​
PRICEV_Y6C
13​
0​
PRICEV_Y7C
13​
0​
 

Kris.D

Member
I was able to read this file successfully using python dbfread, it appears there is additional column at the end called _nullflags.
This column has unprintable characters in rows where not all fields are populated.

For B4J I'm using jdbf-1.3.jar and I think this driver cannot deal with this _nullflags column. Other dbf files that do work don't have this extra column.
I read that this is dbf private field to keep track of the null fields in the record.
 
Upvote 0
Top