I would like to write data from SQL table to DBF file in
Java.
I found a DBF writer
http://priede.bf.lu.lv/ftp/pub/DatuBazes/DBF/javadbf/javadbf-tutorial.html.
It is a useful DBF writer but it is not a flexible one. I mean I should declare the DBF fields in DBFFiled array in advance.
I do not know which data will be selected from SQL that I do not know the length and the indexes of the DBFField array in advance.
I tried to solve this to insert the java codes of javadbf in a
string into one SQL table e.g:
fields[n] = new DBFField();
fields[n].setName( "TIME_ID");
field[n].setDataType( DBFField.FIELD_TYPE_C);
field[n].setFieldLength(20);
and the object rowData[] are in strings e.g:
rowData[n] = result.getDate("Time");
when I select the data from SQL these strings are also selected and put them into one String determined the strings with comma e.g.
String Fields is:
fields[n] = new DBFField();
fields[n].setName( "TIME_ID");
field[n].setDataType( DBFField.FIELD_TYPE_C);
field[n].setFieldLength(20); ,
fields[n] = new DBFField();
fields[n].setName("RH010");
field[n].setDataType(DBFField.FIELD_TYPE_F);
field[n].setFieldLength(20);
I tried to create an abstract class with strings where I used the DBFFileWriter.
The DBFFileWriter needs arrays. I tried to „create” arrays from strings with the following way:
where Filelds is the string which contains the java codes in strings and the resulted S or getFields(i) is e.g:
fields[n] = new DBFField();
fields[n].setName( "TIME_ID");
field[n].setDataType( DBFField.FIELD_TYPE_C);
field[n].setFieldLength(20);
unfortunately, the string S will not get the integer n value that I receive com.linuxense.javadbf.DBFException: Field 0 is null error.
Can someone suggest me a method to fix this issue or a better DBF writer which can write DBF in Java from data in SQL database?
Thank you for your help in advance!