problem solved
On Fri, Feb 17, 2012 at 3:06 PM, Joao Lobo <[email protected]> wrote:
> I followed
> this<http://docs.geotools.org/latest/userguide/library/data/featuresource.html>tutorial
> that explains how can you update data in database, but is not working in
> my case.
>
> 1. I have a method to pass parameters to connect to database:
>
> public Map getParams() {
>> Map params = new HashMap();
>> params.put("dbtype", "postgis");
>> params.put("host", "localhost");
>> params.put("port", new Integer(5432));
>> params.put("schema", "urbanenvironment");
>> params.put("database", "ypenburg");
>> params.put("user", "postgres");
>> params.put("passwd", "postgres");
>> return params;
>> }
>
>
> 2. Create a DataStore (pgDataStore) and try to implement the various steps
> of the transaction in accordance with the example in the tutorial.
> - *u**e_inf_landuse* is the name of the table that I modified on the
> database
> - *Function* is the table column that i want to change in ue_inf_landuse
> table
> - The String function corresponds to the field that I want to change in the
> column function
>
> /**
>>
>> * Ligar a base de dados
>>
>> */
>>
>> Map params = getParams();
>>
>> try {
>>
>> pgDataStore = DataStoreFinder.getDataStore(params);
>>
>> SimpleFeatureStore store = (SimpleFeatureStore)
>>> pgDataStore.getFeatureSource("ue_inf_landuse");
>>
>> Transaction transaction = new DefaultTransaction("Teste");
>>
>> store.setTransaction(transaction);
>>
>> FilterFactory ff =
>>> CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
>>
>> Filter filter = ff.id
>>> (Collections.singleton(ff.featureId(ind.toStringID())));
>>
>>
>>> SimpleFeatureType featureType = store.getSchema();
>>
>> try {
>>
>> store.modifyFeatures("function", function, filter);
>>
>> transaction.commit();
>>
>> } catch (Exception ex) {
>>
>> transaction.rollback();
>>
>> }
>>
>> } catch (IOException ex) {
>>
>> Exceptions.printStackTrace(ex);
>>
>> }
>>
>>
> --
> Com os melhores cumprimentos,
>
> João Lobo
>
--
Com os melhores cumprimentos,
João Lobo
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users