|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectJDBCFeatureWriter
JDBCPSFeatureWriter
public abstract class JDBCPSFeatureWriter
An abstract class that uses prepared statements to insert, update and delete features from the database. Useful when the resultset got from the database is not updatable, and to get peak performance thru the use of prepared statements and batch updates.
Assumptions made by the code:
trunk/gt/modules
(gt-modules.jar
) (Maven report) (SVN head)Field Summary | |
---|---|
protected FIDMapper |
mapper
|
Fields inherited from class JDBCFeatureWriter |
---|
closed, current, fidAttributes, live, queryData, reader |
Constructor Summary | |
---|---|
JDBCPSFeatureWriter(FeatureReader<SimpleFeatureType,SimpleFeature> fReader,
QueryData queryData)
Creates a new instance of JDBCFeatureWriter |
Method Summary | |
---|---|
void |
close()
Release the underlying resources. |
protected PreparedStatement |
createDeleteStatement(Connection conn,
SimpleFeatureType featureType)
Creates the prepared statement for feature deletes |
protected PreparedStatement |
createInsertStatement(Connection conn,
SimpleFeatureType featureType)
Creates the prepared statement for feature inserts |
protected PreparedStatement |
createUpdateStatement(Connection conn,
SimpleFeatureType featureType)
Creates the prepared statement for feature updates |
protected void |
doInsert(MutableFIDFeature current)
Override that uses prepared statements to perform the operation. |
protected void |
doUpdate(SimpleFeature live,
SimpleFeature current)
Override that uses sql statements to perform the operation. |
protected void |
executeInsert(PreparedStatement insertStatement)
Hook for subclasses to use a specific execution mechanism other than the default insertStatement.executeUpdate() . |
protected abstract String |
getGeometryPlaceHolder(AttributeDescriptor type)
Returns the placeholder for the geometry in the insert/update statement. |
protected PreparedStatement |
prepareInsertStatement(Connection conn,
StringBuffer statementSQL,
SimpleFeatureType featureType)
Provides a hook for subclasses to fine tune the creation of the prepared statement. |
protected void |
remove(MutableFIDFeature current)
Override that uses prepared statements to perform the operation. |
protected boolean |
useQueryDataForInsert()
This version does not use QueryData udpate/insert/remove methods, but uses separate prepared statements instead |
Methods inherited from class JDBCFeatureWriter |
---|
encodeColumnName, encodeName, getFeatureType, hasNext, next, remove, write |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final FIDMapper mapper
Constructor Detail |
---|
public JDBCPSFeatureWriter(FeatureReader<SimpleFeatureType,SimpleFeature> fReader, QueryData queryData) throws IOException
fReader
- queryData
-
IOException
Method Detail |
---|
protected void doInsert(MutableFIDFeature current) throws IOException, SQLException
doInsert
in class JDBCFeatureWriter
IOException
SQLException
JDBCFeatureWriter.doInsert(org.geotools.data.jdbc.MutableFIDFeature)
protected void executeInsert(PreparedStatement insertStatement) throws IOException
insertStatement.executeUpdate()
.
Override may be needed in some cases, for example, where the execution expects a ResultSet containing the autogenerated primary key.
insertStatement
- the insert statement prepared in doInsert(MutableFIDFeature)
IOException
protected PreparedStatement createInsertStatement(Connection conn, SimpleFeatureType featureType) throws SQLException
conn
- featureType
-
SQLException
protected PreparedStatement prepareInsertStatement(Connection conn, StringBuffer statementSQL, SimpleFeatureType featureType) throws SQLException
This default implementation just creates the statement with the given connetion and
the insert request built at createInsertStatement(java.sql.Connection, org.opengis.feature.simple.SimpleFeatureType)
conn
- statementSQL
- featureType
-
SQLException
protected abstract String getGeometryPlaceHolder(AttributeDescriptor type)
type
- protected void remove(MutableFIDFeature current) throws IOException, SQLException
IOException
SQLException
JDBCFeatureWriter.doInsert(org.geotools.data.jdbc.MutableFIDFeature)
protected PreparedStatement createDeleteStatement(Connection conn, SimpleFeatureType featureType) throws SQLException
conn
- featureType
-
SQLException
protected PreparedStatement createUpdateStatement(Connection conn, SimpleFeatureType featureType) throws SQLException
conn
- featureType
-
SQLException
protected void doUpdate(SimpleFeature live, SimpleFeature current) throws IOException, SQLException
doUpdate
in class JDBCFeatureWriter
IOException
SQLException
org.geotools.data.jdbc.JDBCFeatureWriter#doUpdate(org.geotools.feature.Feature,
org.geotools.feature.Feature)
protected boolean useQueryDataForInsert()
useQueryDataForInsert
in class JDBCFeatureWriter
JDBCFeatureWriter.useQueryDataForInsert()
public void close() throws IOException
FeatureWriter
close
in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
close
in class JDBCFeatureWriter
IOException
- if there there are problems releasing underlying resources, or
possibly if close has been called (up to the implementation).FeatureWriter.close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |