[Gvsig_english] Errors while modifying a dbasefile
Jose Manuel Vivó (Chema)
josemanuel.vivo at iver.es
Mon May 28 08:28:26 CEST 2007
Hi Matthieu,
El Martes 22 Mayo 2007 17:32, Matthieu Voorons escribió:
> Hi list,
> I'm still trying to play with a dbf file. I don't have any problem to
> read the file and make some basic queries, but I have some problems when
> I try to modify and save the dbasefile.
> I get a null pointer exception when I try to add a new record to the dbase.
> String expression = insert into properties(NAME,STREET,CITY,ZIP)
> values (myname,myroad,mycity,88818);
> DataSource ds = sds.getDataSourceFactory().executeSQL(expression,
> DataSourceFactory.AUTOMATIC_OPENING); //here I get a nullpointerexception
> Do I have to specify somewhere that I am in editing mode ? Is there
> another way to simply add a record to a dbase?
You can't use the gvSIG SQL Parser for modify data or table structure.
>
> What should I do if I want to save the modified dbasefile (in a new file
> or not) ?
> I tried :
> SelectableDataSource sds = new
> SelectableDataSource(dataSource);//the data to save
> EditableAdapter auxea = new EditableAdapter();
> auxea.setOriginalDataSource(sds);
> DbfWriter writer = new DbfWriter();
> writer.setFile(new File("c:\\savedDbf.dbf"));
> try {
> auxea.saveEdits(writer, EditionEvent.ALPHANUMERIC);
> } catch (EditionException ex) {
> ex.printStackTrace();
> }
> but I get a nullpointerexception on the line auxea.saveEdits
> Exception in thread "main" java.lang.NullPointerException
> at
> com.iver.cit.gvsig.fmap.edition.writers.dbf.DbfWriter.getFields(DbfWriter.j
>ava:229) at
> com.iver.cit.gvsig.fmap.edition.writers.dbf.DbfWriter.alterTable(DbfWriter.
>java:180) at
> com.iver.cit.gvsig.fmap.edition.writers.dbf.DbfWriter.preProcess(DbfWriter.
>java:80) at
> com.iver.cit.gvsig.fmap.edition.EditableAdapter.saveEdits(EditableAdapter.j
>ava:316)
You can find the code for do it in the file 'ExportTo.java' (extCAD proyect)
>
> Is there someting I'm missing there?
> Thanks for your replies, regards,
> Matthieu
Regards
Chema.
--
=============
Jose Manuel Vivó (Chema)
Equipo de gvSIG
IVER T.I. S.A.
C/ Salamanca, 50-52
46005-Valencia
Tlf.+34963163400
Spain
www.iver.es
www.gvsig.com
More information about the Gvsig_internacional
mailing list