org.geotools.data.jdbc
Class JDBCTextFeatureWriter

Object
  extended by JDBCFeatureWriter
      extended by JDBCTextFeatureWriter
All Implemented Interfaces:
FeatureWriter<SimpleFeatureType,SimpleFeature>
Direct Known Subclasses:
DB2FeatureWriter, PostgisFeatureWriter

Deprecated. scheduled for removal in 2.7, use classes in org.geotools.jdbc

public abstract class JDBCTextFeatureWriter
extends JDBCFeatureWriter

An abstract class that uses sql statements to insert, update and delete features from the database. Useful when the resultset got from the database is not updatable, for example.

Author:
Andrea Aime, chorner
Module:
modules/library/jdbc (gt-jdbc.jar)
TODO:
TODO: Use prepared statements for inserts. Jody says that oracle at least will perform faster, and I imagine postgis will too. This will require a bit of rearchitecture, since the statement should just be made once, right now even if there were many features coming in they would all have to make a new prepared statement - should be able to do it before and then just fill it up for each feature. And for oracle Jody has some convenience methods in his SDO stuff that works with prepared statements and STRUCTS directly. See http://jira.codehaus.org/browse/GEOT-219 (close when done).

Field Summary
protected  FIDMapper mapper
          Deprecated.  
 
Fields inherited from class JDBCFeatureWriter
closed, current, fidAttributes, live, queryData, reader
 
Constructor Summary
JDBCTextFeatureWriter(FeatureReader<SimpleFeatureType,SimpleFeature> fReader, QueryData queryData)
          Deprecated. Creates a new instance of JDBCFeatureWriter
 
Method Summary
protected  String addQuotes(Object value)
          Deprecated. Adds quotes to an object for storage in postgis.
protected  void doInsert(MutableFIDFeature current)
          Deprecated. Override that uses sql statements to perform the operation.
protected  void doUpdate(SimpleFeature live, SimpleFeature current)
          Deprecated. Override that uses sql statements to perform the operation.
protected abstract  String getGeometryInsertText(Geometry geom, int srid)
          Deprecated. Turns a geometry into the textual version needed for the sql statement
protected  String getGeometryInsertText(Geometry geom, int srid, int dimension)
          Deprecated. Turns a geometry into the textual version needed for the sql statement
protected  String makeDeleteSql(SimpleFeature feature)
          Deprecated. Generates the query for the sql delete statement
protected  String makeInsertSql(SimpleFeature feature)
          Deprecated. Creates a sql insert statement.
protected  String makeSelectForUpdateSql(SimpleFeature current)
          Deprecated. Generate the select for update statement, which will attempt to lock features for update.
protected  String makeUpdateSql(SimpleFeature live, SimpleFeature current)
          Deprecated. Generate the update sql statement
 void remove()
          Deprecated. Override that uses sql statements to perform the operation.
protected  boolean useQueryDataForInsert()
          Deprecated. This version does not use QueryData udpate/insert/remove methods, but uses separate queries instead
 
Methods inherited from class JDBCFeatureWriter
close, encodeColumnName, encodeName, getFeatureType, hasNext, next, write
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapper

protected FIDMapper mapper
Deprecated. 
Constructor Detail

JDBCTextFeatureWriter

public JDBCTextFeatureWriter(FeatureReader<SimpleFeatureType,SimpleFeature> fReader,
                             QueryData queryData)
                      throws IOException
Deprecated. 
Creates a new instance of JDBCFeatureWriter

Parameters:
fReader -
queryData -
Throws:
IOException
Method Detail

doInsert

protected void doInsert(MutableFIDFeature current)
                 throws IOException,
                        SQLException
Deprecated. 
Override that uses sql statements to perform the operation.

Overrides:
doInsert in class JDBCFeatureWriter
Throws:
IOException
SQLException
See Also:
JDBCFeatureWriter.doInsert(org.geotools.data.jdbc.MutableFIDFeature)

makeInsertSql

protected String makeInsertSql(SimpleFeature feature)
                        throws IOException
Deprecated. 
Creates a sql insert statement. Uses each feature's schema, which makes it possible to insert out of order, as well as inserting less than all features.

Parameters:
feature - the feature to add.
Returns:
an insert sql statement.
Throws:
IOException

addQuotes

protected String addQuotes(Object value)
Deprecated. 
Adds quotes to an object for storage in postgis. The object should be a string or a number. To perform an insert strings need quotes around them, and numbers work fine with quotes, so this method can be called on unknown objects.

Parameters:
value - The object to add quotes to.
Returns:
a string representation of the object with quotes.

getGeometryInsertText

protected abstract String getGeometryInsertText(Geometry geom,
                                                int srid)
                                         throws IOException
Deprecated. 
Turns a geometry into the textual version needed for the sql statement

Parameters:
geom -
srid -
Throws:
IOException

getGeometryInsertText

protected String getGeometryInsertText(Geometry geom,
                                       int srid,
                                       int dimension)
                                throws IOException
Deprecated. 
Turns a geometry into the textual version needed for the sql statement

Parameters:
geom -
srid -
dimension -
Throws:
IOException

remove

public void remove()
            throws IOException
Deprecated. 
Override that uses sql statements to perform the operation.

Specified by:
remove in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
Overrides:
remove in class JDBCFeatureWriter
Throws:
IOException - DOCUMENT ME!
See Also:
FeatureWriter.remove()

makeDeleteSql

protected String makeDeleteSql(SimpleFeature feature)
                        throws IOException
Deprecated. 
Generates the query for the sql delete statement

Parameters:
feature -
Throws:
IOException

doUpdate

protected void doUpdate(SimpleFeature live,
                        SimpleFeature current)
                 throws IOException,
                        SQLException
Deprecated. 
Override that uses sql statements to perform the operation.

Overrides:
doUpdate in class JDBCFeatureWriter
Throws:
IOException
SQLException
See Also:
org.geotools.data.jdbc.JDBCFeatureWriter#doUpdate(org.geotools.feature.Feature, org.geotools.feature.Feature)

makeSelectForUpdateSql

protected String makeSelectForUpdateSql(SimpleFeature current)
Deprecated. 
Generate the select for update statement, which will attempt to lock features for update. This should be overwritten by databases which want to take advantage of this method. This method is called in a timer thread, to prevent blocking.

Parameters:
current -
Returns:
sql string or null
Since:
2.2.0

makeUpdateSql

protected String makeUpdateSql(SimpleFeature live,
                               SimpleFeature current)
                        throws IOException
Deprecated. 
Generate the update sql statement

Parameters:
live -
current -
Throws:
IOException

useQueryDataForInsert

protected boolean useQueryDataForInsert()
Deprecated. 
This version does not use QueryData udpate/insert/remove methods, but uses separate queries instead

Overrides:
useQueryDataForInsert in class JDBCFeatureWriter
See Also:
JDBCFeatureWriter.useQueryDataForInsert()


Copyright © 1996-2009 Geotools. All Rights Reserved.