[Gvsig_english] Re: GDBMS executeSQL to update a column

Olivier Ertz olivier.ertz at heig-vd.ch
Thu Dec 14 13:34:57 CET 2006


So I try to post again on the list, just for archive, here is the 
question and already the answer I got by a direct way from Chema.
Thanx to him.

--

Hello, Oliver

El Miércoles 13 Diciembre 2006 14:25, escribió:
> Hi,
> Thanx Chema about how to a DataSource after an addFileDataSource. I
> could not guess the first solution you gave.
>
> I sent the following message to the international list, but did not
> appear in the list. Are you able to know why some messages are dropped ?
I don't know, sorry.

>
> Sorry, then I send you directly my question and as it seems you are the
> "GDBMS boss", it will probably be easy for you to answer ;-) :
i'll try to do it best ;-)

>
> I tested the executeSQL with an update SQL query, something like :
>
> String sql="update " + dsName + " set POP1990 = 999;";
> SelectableDataSource result = new
> SelectableDataSource(LayerFactory.getDataSourceFactory()
>                  .executeSQL(sql, DataSourceFactory.MANUAL_OPENING));

The GDBMS version that uses gvSIG doesn't support the SQL sentences that 
alter
the data or structure of the data base.

>
> But I get :
> java.lang.NullPointerException
>      at
> com.hardcode.gdbms.engine.instruction.Utilities.buildTree(Utilities.java:15
>8) at
> com.hardcode.gdbms.engine.data.DataSourceFactory.executeSQL(DataSourceFacto
>ry.java:1660) ...
>
> With a wrong syntax, I should get the usual exception telling what is
> expected in the query syntax... but here I get a NullPointerException !

I think it's a bug, but i have to investigate it a bit more.


> Does this inspire you ? Do you have an example with an update query ?
gvSIG doesn't use the GDBMS library to write data. You can find a 
example of
this in the class ExportTo in the extCad project.

In any case, the support for the modification of data implemented in GDBMS
(the gvSIG version) becomes through DataWare interface. Here you are a 
short
example of that works:

     ds = dataSourceFactory.createRandomDataSource("posgres_tabla2");
     DataWare dw = ds.getDataWare(DataSourceFactory.DATA_WARE_DIRECT_MODE);
     dw.beginTrans();
     Value[] value = {
           ValueFactory.createValue("a"),
           ValueFactory.createValue("b"),
           ValueFactory.createValue("c")
     };
     dw.insertFilledRow(value);
     dw.commitTrans();

DataWare objets it's a kind of modifications list. When  method 
'commitTrans'
is called it delegates on the Driver to make these changes in order.

I didn't make many tests to the DataWare, so i can't recommend you this. In
addition, they finish to me informing that, the author of the bookstore, 
was
working in it just before going away of the company.


>
> Thanks in advance for your answer.
> Olivier.

I hope these notes will help you.

Regards.
Chema.
-- 
=============
Jose Manuel Vivó (Chema)
Equipo de gvSIG

IVER T.I. S.A.
c/Salamanca 50
46005 Valencia
Spain


-------------- next part --------------
A non-text attachment was scrubbed...
Name: olivier.ertz.vcf
Type: text/x-vcard
Size: 240 bytes
Desc: not available
Url : http://runas.cap.gva.es/pipermail/gvsig_internacional/attachments/20061214/848da43b/olivier.ertz.vcf


More information about the Gvsig_internacional mailing list