Closed JosepMariaGomez closed 2 years ago
As far as I know you can not write smallint in dbf files. Could you provide a sample flie or a link to some specification including that smallint datatype?
Hi Alberto, many thanks for the answer. I put 2 images from a DBFFile with Smallint fields.
Muchas gracias!
I'm surprised, dbaseIII doesn't have a "smallint" datatype, maybe your driver / program is using this as an alias for a dbase type.
Could you try to read your file with this example code to print table structure to console
public static void main(String[] args) throws Exception {
writeToConsole(new File(args[0]));
}
public static void writeToConsole(File file) throws FileNotFoundException {
DBFReader reader = null;
try {
reader = new DBFReader(new BufferedInputStream(new FileInputStream(file)));
int numberOfFields = reader.getFieldCount();
for (int i = 0; i < numberOfFields; i++) {
DBFField field = reader.getField(i);
System.out.println(field.getType() + " (" + field.getLength() + ") "+ field.getName());
}
}
finally {
DBFUtils.close(reader);
}
}
If the output doesn't clarify the datatype used for "smallint", you could send a sample file without confidential data.
Thanks Alberto,
done!!
Result: ... IDNIF NUMERIC (1,0) CODPAIS CHARACTER (2,0) REP14NIF CHARACTER (9,0) REP14NOM CHARACTER (40,0) METCOBRO LOGICAL (1,0) METCOBFRE LOGICAL (1,0) SUPLIDO LOGICAL (1,0) PROVISION LOGICAL (1,0) LESIRPF LOGICAL (1,0) NIRPF NUMERIC (16,2) NCLAVEIRPF NUMERIC (2,0) LESMOD130 LOGICAL (1,0) LDEDUCIBLE LOGICAL (1,0)
IDNIF and NCLAVEIRPF are defined as NUMERIC(1,0) and Numeric(2,0) and are readed by Vitaly Levchencko's Database Tour as SmallInt...
I've tried also to read the structure with Borland Database Desktop and the result is the same as with your driver says:
I'll try to create them like Numeric(1,0) and Numeric(2,0) and to see if are readed by the external app.
Thanks a Lot!!!
Hi Alberto, creating fields as javadbf says, the fields are created well and moderns programs thats opens the dbf, it reads as Smallint.
Many thanks.
I'm trying to write a DBF with smallInt field, but is not supported. How can I write it?
Many thanks and good work!!