org.geotools.jdbc
Class PreparedStatementSQLDialect

Object
  extended by SQLDialect
      extended by PreparedStatementSQLDialect
Direct Known Subclasses:
DB2SQLDialectPrepared, GeoPkgDialect, H2DialectPrepared, MySQLDialectPrepared, OracleDialect, PostGISPSDialect, TeradataDialect

public abstract class PreparedStatementSQLDialect
extends SQLDialect

SQL dialect which uses prepared statements for database interaction.

Author:
Justin Deoliveira, OpenGEO

Field Summary
 
Fields inherited from class SQLDialect
BASE_DBMS_CAPABILITIES, dataStore, LOGGER
 
Constructor Summary
protected PreparedStatementSQLDialect(JDBCDataStore dataStore)
           
 
Method Summary
 PreparedFilterToSQL createPreparedFilterToSQL()
           
 void onDelete(PreparedStatement delete, Connection cx, SimpleFeatureType featureType)
          Callback invoked before a DELETE statement is executed against the database.
 void onInsert(PreparedStatement insert, Connection cx, SimpleFeatureType featureType)
          Callback invoked before an INSERT statement is executed against the database.
 void onSelect(PreparedStatement select, Connection cx, SimpleFeatureType featureType)
          Callback invoked before a SELECT statement is executed against the database.
 void onUpdate(PreparedStatement update, Connection cx, SimpleFeatureType featureType)
          Callback invoked before an UPDATE statement is executed against the database.
 void prepareFunctionArgument(Class clazz, StringBuffer sql)
          Prepares a function argument for a prepared statement.
 void prepareGeometryValue(Geometry g, int dimension, int srid, Class binding, StringBuffer sql)
          Prepares the geometry value for a prepared statement.
abstract  void setGeometryValue(Geometry g, int dimension, int srid, Class binding, PreparedStatement ps, int column)
          Sets the geometry value into the prepared statement.
 void setValue(Object value, Class binding, PreparedStatement ps, int column, Connection cx)
          Sets a value in a prepared statement, for "basic types" (non-geometry).
 
Methods inherited from class SQLDialect
addSupportedHints, applyLimitOffset, createCRS, createIndex, decodeGeometryEnvelope, decodeGeometryValue, decodeGeometryValue, dropIndex, encodeColumnAlias, encodeColumnName, encodeColumnName, encodeColumnType, encodeGeometryColumn, encodeGeometryColumn, encodeGeometryColumn, encodeGeometryColumnGeneralized, encodeGeometryColumnGeneralized, encodeGeometryColumnSimplified, encodeGeometryColumnSimplified, encodeGeometryEnvelope, encodeJoin, encodePostColumnCreateTable, encodePostCreateTable, encodePostSelect, encodePrimaryKey, encodeSchemaName, encodeTableAlias, encodeTableName, getDefaultVarcharSize, getGeometryDimension, getGeometrySRID, getGeometryTypeName, getIndexes, getLastAutoGeneratedValue, getMapping, getNameEscape, getNextAutoGeneratedValue, getNextSequenceValue, getOptimizedBounds, getSequenceForColumn, handleUserDefinedType, includeTable, initializeConnection, isAutoCommitQuery, isLimitOffsetSupported, lookupGeneratedValuesPostInsert, ne, postCreateAttribute, postCreateFeatureType, postCreateTable, postDropTable, preDropTable, registerAggregateFunctions, registerClassToSqlMappings, registerSqlTypeNameToClassMappings, registerSqlTypeToClassMappings, registerSqlTypeToSqlTypeNameOverrides
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreparedStatementSQLDialect

protected PreparedStatementSQLDialect(JDBCDataStore dataStore)
Method Detail

prepareGeometryValue

public void prepareGeometryValue(Geometry g,
                                 int dimension,
                                 int srid,
                                 Class binding,
                                 StringBuffer sql)
Prepares the geometry value for a prepared statement.

This method should be overridden if the implementation needs to wrap the geometry placeholder in the function. The default implementationg just appends the default placeholder: '?'.

Parameters:
g - The geometry value.
srid - The spatial reference system of the geometry, or -1 if unknown
dimension - The dimensions (2,3,4) of the coordinates, or -1 if unknown
binding - The class of the geometry.
sql - The prepared sql statement buffer.

prepareFunctionArgument

public void prepareFunctionArgument(Class clazz,
                                    StringBuffer sql)
Prepares a function argument for a prepared statement.

Parameters:
clazz - The mapped class of the argument.
sql - The prepared sql statement buffer

setGeometryValue

public abstract void setGeometryValue(Geometry g,
                                      int dimension,
                                      int srid,
                                      Class binding,
                                      PreparedStatement ps,
                                      int column)
                               throws SQLException
Sets the geometry value into the prepared statement.

Parameters:
g - The geometry
srid - the geometry native srid (should be forced into the encoded geometry)
binding - the geometry type
ps - the prepared statement
column - the column index where the geometry is to be set
Throws:
SQLException

setValue

public void setValue(Object value,
                     Class binding,
                     PreparedStatement ps,
                     int column,
                     Connection cx)
              throws SQLException
Sets a value in a prepared statement, for "basic types" (non-geometry).

Subclasses should override this method if they need to do something custom or they wish to support non-standard types.

Parameters:
value - the value.
binding - The class of the value.
ps - The prepared statement.
column - The column the value maps to.
cx - The database connection.
Throws:
SQLException

createPreparedFilterToSQL

public PreparedFilterToSQL createPreparedFilterToSQL()

onSelect

public void onSelect(PreparedStatement select,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before a SELECT statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
select - The select statement being executed
cx - The database connection
featureType - The feature type the select is executing against.
Throws:
SQLException

onDelete

public void onDelete(PreparedStatement delete,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before a DELETE statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
delete - The delete statement being executed
cx - The database connection
featureType - The feature type the delete is executing against.
Throws:
SQLException

onInsert

public void onInsert(PreparedStatement insert,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before an INSERT statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
insert - The delete statement being executed
cx - The database connection
featureType - The feature type the insert is executing against.
Throws:
SQLException

onUpdate

public void onUpdate(PreparedStatement update,
                     Connection cx,
                     SimpleFeatureType featureType)
              throws SQLException
Callback invoked before an UPDATE statement is executed against the database.

The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

Parameters:
update - The delete statement being executed
cx - The database connection
featureType - The feature type the update is executing against.
Throws:
SQLException


Copyright © 1996-2014 Geotools. All Rights Reserved.