|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.data.store.ContentDataStore
org.geotools.jdbc.JDBCDataStore
public final class JDBCDataStore
Datastore implementation for jdbc based relational databases.
This class is not intended to be subclassed on a per database basis. Instead the notion of a "dialect" is used.
SQLDialect
) encapsulates all the operations that are database
specific. Therefore to implement a jdbc based datastore one must extend SQLDialect.
The specific dialect to use is set using setSQLDialect(SQLDialect)
.
DataSource
.
A datastore must be specified using setDataSource(DataSource)
.
setDatabaseSchema(String)
.
FilterCapabilities
instance.
This is specified using #setFilterCapabilities(FilterCapabilities)
.
Field Summary | |
---|---|
protected java.util.HashMap<java.lang.Class<? extends org.opengis.feature.FeatureVisitor>,java.lang.String> |
aggregateFunctions
Feature visitor to aggregate function name |
protected boolean |
associations
flag controlling if the datastore is supporting feature and geometry relationships with associations |
protected java.util.HashMap<java.lang.Class<?>,java.lang.Integer> |
classToSqlTypeMappings
java class to sql type mappings; |
protected java.lang.String |
databaseSchema
The database schema. |
protected javax.sql.DataSource |
dataSource
data source |
protected static PrimaryKeyFinder |
DEFAULT_PRIMARY_KEY_FINDER
The default primary key finder, looks in the default metadata table first, uses heuristics later |
protected SQLDialect |
dialect
the dialect of sql |
protected static ReferencedEnvelope |
EMPTY_ENVELOPE
The envelope returned when bounds is called against a geometryless feature type |
protected boolean |
exposePrimaryKeyColumns
flag controlling whether primary key columns of a table are exposed via the feature type. |
protected static java.lang.String |
FEATURE_ASSOCIATION_TABLE
name of table to use to store feature associations when associations
is set. |
protected static java.lang.String |
FEATURE_RELATIONSHIP_TABLE
name of table to use to store feature relationships (information about associations) when associations is set. |
protected int |
fetchSize
The fetch size for this datastore, defaulting to 1000. |
protected static java.lang.String |
GEOMETRY_ASSOCIATION_TABLE
name of table to use to store geometry associations when associations
is set. |
protected static java.lang.String |
GEOMETRY_TABLE
name of table to use to store geometries when associations
is set. |
static java.lang.String |
JDBC_NATIVE_SRID
The native SRID associated to a certain descriptor TODO: qualify this key with 'org.geotools.jdbc' |
static java.lang.String |
JDBC_NATIVE_TYPENAME
The key for attribute descriptor user data which specifies the original database column data type. |
static java.lang.String |
JDBC_READ_ONLY
Boolean marker stating whether the feature type is to be considered read only |
protected static java.lang.String |
MULTI_GEOMETRY_TABLE
name of table to use to store multi geometries made up of non-multi geometries when associations is set. |
protected PrimaryKeyFinder |
primaryKeyFinder
Finds the primary key definitions |
protected java.util.HashMap<java.lang.String,java.lang.Class<?>> |
sqlTypeNameToClassMappings
sql type name to java class mappings |
protected java.util.HashMap<java.lang.Integer,java.lang.Class<?>> |
sqlTypeToClassMappings
sql type to java class mappings |
protected java.util.HashMap<java.lang.Integer,java.lang.String> |
sqlTypeToSqlTypeNameOverrides
sql type to sql type name overrides |
Fields inherited from class org.geotools.data.store.ContentDataStore |
---|
dataStoreFactory, entries, featureFactory, filterFactory, geometryFactory, lockingManager, LOGGER, namespaceURI, typeFactory, WRITER_ADD, WRITER_UPDATE |
Constructor Summary | |
---|---|
JDBCDataStore()
|
Method Summary | ||
---|---|---|
Transaction |
buildTransaction(java.sql.Connection cx)
Builds a transaction object around a user provided connection. |
|
void |
closeSafe(java.sql.Connection cx)
Utility method for closing a connection. |
|
void |
closeSafe(java.sql.ResultSet rs)
Utility method for closing a result set. |
|
void |
closeSafe(java.sql.Statement st)
Utility method for closing a statement. |
|
protected java.lang.String |
createAssociationTableSQL(java.sql.Connection cx)
Creates the sql for the association table. |
|
protected java.sql.Connection |
createConnection()
Creates a new connection. |
|
protected ContentState |
createContentState(ContentEntry entry)
Creates an instanceof JDBCState . |
|
protected ContentFeatureSource |
createFeatureSource(ContentEntry entry)
Creates a new instance of JDBCFeatureStore . |
|
protected FilterToSQL |
createFilterToSQL(org.opengis.feature.simple.SimpleFeatureType featureType)
Creates a new instance of a filter to sql encoder. |
|
protected java.lang.String |
createGeometryAssociationTableSQL(java.sql.Connection cx)
Creates the sql for the geometry association table. |
|
protected java.lang.String |
createGeometryTableSQL(java.sql.Connection cx)
Creates the sql for the geometry table. |
|
protected java.lang.String |
createMultiGeometryTableSQL(java.sql.Connection cx)
Creates the sql for the multi_geometry table. |
|
protected PreparedFilterToSQL |
createPreparedFilterToSQL(org.opengis.feature.simple.SimpleFeatureType featureType)
Creates a new instance of a filter to sql encoder to be used in a prepared statement. |
|
protected java.lang.String |
createRelationshipTableSQL(java.sql.Connection cx)
Creates the sql for the relationship table. |
|
void |
createSchema(org.opengis.feature.simple.SimpleFeatureType featureType)
Creates a table in the underlying database from the specified table. |
|
protected java.lang.String |
createTableSQL(org.opengis.feature.simple.SimpleFeatureType featureType,
java.sql.Connection cx)
Generates a 'CREATE TABLE' sql statement. |
|
protected java.util.List |
createTypeNames()
Generates the list of type names provided by the database. |
|
protected java.util.List<java.lang.Object> |
decodeFID(PrimaryKey key,
java.lang.String FID,
boolean strict)
Decodes a fid into its components based on a primary key. |
|
protected void |
delete(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.filter.Filter filter,
java.sql.Connection cx)
Deletes an existing feature(s) in the database for a particular feature type / table. |
|
protected void |
delete(org.opengis.feature.simple.SimpleFeatureType featureType,
java.lang.String fid,
java.sql.Connection cx)
Deletes an existing feature in the database for a particular feature type / fid. |
|
protected java.lang.String |
deleteSQL(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.filter.Filter filter)
Generates a 'DELETE FROM' sql statement. |
|
protected java.sql.PreparedStatement |
deleteSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.filter.Filter filter,
java.sql.Connection cx)
Generates a 'DELETE FROM' prepared statement. |
|
void |
dispose()
Disposes of this data store and releases any resource that it is using. |
|
protected java.lang.String |
encodeFID(java.util.List<java.lang.Object> keyValues)
|
|
protected java.lang.String |
encodeFID(PrimaryKey pkey,
java.sql.ResultSet rs)
Encodes a feature id from a primary key and result set values. |
|
protected void |
encodeFunction(java.lang.String function,
org.opengis.feature.type.AttributeDescriptor att,
Query query,
java.lang.StringBuffer sql)
|
|
protected void |
encodeGeometryColumn(org.opengis.feature.type.GeometryDescriptor gatt,
java.lang.StringBuffer sql,
Hints hints)
Encoding a geometry column with respect to hints Supported Hints are provided by SQLDialect.addSupportedHints(Set) |
|
protected void |
encodeTableName(java.lang.String tableName,
java.lang.StringBuffer sql)
Helper method to encode table name which checks if a schema is set and prefixes the table name with it. |
|
protected void |
ensureAssociationTablesExist(java.sql.Connection cx)
Helper method for creating geometry association table if it does not exist. |
|
protected void |
ensureAuthorization(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.filter.Filter filter,
Transaction tx,
java.sql.Connection cx)
Ensures that that the specified transaction has access to features specified by a filter. |
|
protected void |
finalize()
|
|
java.util.Map<java.lang.Class<? extends org.opengis.feature.FeatureVisitor>,java.lang.String> |
getAggregateFunctions()
Returns the supported aggregate functions and the visitors they map to. |
|
protected java.lang.Object |
getAggregateValue(org.opengis.feature.FeatureVisitor visitor,
org.opengis.feature.simple.SimpleFeatureType featureType,
Query query,
java.sql.Connection cx)
Results the value of an aggregate function over a query. |
|
protected ReferencedEnvelope |
getBounds(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query,
java.sql.Connection cx)
Returns the bounds of the features for a particular feature type / table. |
|
java.util.Map<java.lang.Class<?>,java.lang.Integer> |
getClassToSqlTypeMappings()
The java type to sql type mappings that the datastore uses when reading and writing objects to and from the database. |
|
protected java.util.LinkedHashSet<java.lang.String> |
getColumnNames(PrimaryKey key)
Returns the set of the primary key column names. |
|
protected java.lang.Class |
getColumnType(java.sql.DatabaseMetaData metaData,
java.lang.String databaseSchema2,
java.lang.String tableName,
java.lang.String columnName)
Returns the type of the column by inspecting the metadata, with the collaboration of the dialect |
|
protected java.sql.Connection |
getConnection(JDBCState state)
Gets a database connection for the specified feature store. |
|
java.sql.Connection |
getConnection(Transaction t)
Returns a JDCB Connection to the underlying database for the specified GeoTools Transaction . |
|
protected int |
getCount(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query,
java.sql.Connection cx)
Returns the count of the features for a particular feature type / table. |
|
java.lang.String |
getDatabaseSchema()
The schema from which this datastore is serving tables from. |
|
javax.sql.DataSource |
getDataSource()
The data source the datastore uses to obtain connections to the underlying database. |
|
protected int |
getDescriptorSRID(org.opengis.feature.type.AttributeDescriptor descriptor)
Extracts the eventual native SRID user property from the descriptor, returns -1 if not found |
|
int |
getFetchSize()
The current fetch size. |
|
FilterCapabilities |
getFilterCapabilities()
The filter capabilities which reports which spatial operations the underlying database can handle natively. |
|
protected int |
getGeometrySRID(com.vividsolutions.jts.geom.Geometry g,
org.opengis.feature.type.AttributeDescriptor descriptor)
Looks up the geometry srs by trying a number of heuristics. |
|
java.lang.Object |
getGmlObject(org.opengis.filter.identity.GmlObjectId id,
Hints hints)
Looks up an object by its gml id. |
|
protected java.lang.Object |
getLastValue(PrimaryKeyColumn col,
PrimaryKey pkey,
java.sql.Connection cx)
Gets the last value of a generated primary key column. |
|
protected java.util.List<java.lang.Object> |
getLastValues(PrimaryKey pkey,
java.sql.Connection cx)
Gets the last value of a generated primary key. |
|
java.lang.Integer |
getMapping(java.lang.Class<?> clazz)
Returns the sql type mapped to the specified java type. |
|
java.lang.Class<?> |
getMapping(int sqlType)
Returns the java type mapped to the specified sql type. |
|
java.lang.Class<?> |
getMapping(java.lang.String sqlTypeName)
Returns the java type mapped to the specified sql type name. |
|
protected java.lang.Object |
getNextValue(PrimaryKeyColumn col,
PrimaryKey pkey,
java.sql.Connection cx)
Gets the next value for the column of a primary key. |
|
protected java.util.List<java.lang.Object> |
getNextValues(PrimaryKey pkey,
java.sql.Connection cx)
Gets the next value of a primary key. |
|
protected PrimaryKey |
getPrimaryKey(ContentEntry entry)
Returns the primary key object for a particular entry, deriving it from the underlying database metadata. |
|
protected PrimaryKey |
getPrimaryKey(org.opengis.feature.simple.SimpleFeatureType featureType)
Returns the primary key object for a particular feature type / table, deriving it from the underlying database metadata. |
|
PrimaryKeyFinder |
getPrimaryKeyFinder()
Returns the finder used to build PrimaryKey representations |
|
protected java.lang.String |
getPropertyName(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.filter.expression.PropertyName propertyName)
Helper method for executing a property name against a feature type. |
|
SQLDialect |
getSQLDialect()
The dialect the datastore uses to generate sql statements in order to communicate with the underlying database. |
|
java.util.Map<java.lang.String,java.lang.Class<?>> |
getSqlTypeNameToClassMappings()
The sql type name to java type mappings that the dialect uses when reading and writing objects to and from the database. |
|
java.util.Map<java.lang.Integer,java.lang.Class<?>> |
getSqlTypeToClassMappings()
The sql type to java type mappings that the datastore uses when reading and writing objects to and from the database. |
|
java.util.Map<java.lang.Integer,java.lang.String> |
getSqlTypeToSqlTypeNameOverrides()
Returns any ovverides which map integer constants for database types (from Types )
to database type names. |
|
protected
|
initializeFilterToSQL(F toSQL,
org.opengis.feature.simple.SimpleFeatureType featureType)
Helper method to initialize a filter encoder instance. |
|
protected void |
insert(java.util.Collection features,
org.opengis.feature.simple.SimpleFeatureType featureType,
java.sql.Connection cx)
Inserts a collection of new features into the database for a particular feature type / table. |
|
protected void |
insert(org.opengis.feature.simple.SimpleFeature feature,
org.opengis.feature.simple.SimpleFeatureType featureType,
java.sql.Connection cx)
Inserts a new feature into the database for a particular feature type / table. |
|
protected java.lang.String |
insertSQL(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.feature.simple.SimpleFeature feature,
java.util.List keyValues,
java.sql.Connection cx)
Generates a 'INSERT INFO' sql statement. |
|
protected java.sql.PreparedStatement |
insertSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.feature.simple.SimpleFeature feature,
java.util.List keyValues,
java.sql.Connection cx)
Generates a 'INSERT INFO' prepared statement. |
|
boolean |
isAssociations()
Flag controlling if the datastore is supporting feature and geometry relationships with associations |
|
boolean |
isExposePrimaryKeyColumns()
Determines if the datastore creates feature types which include those columns / attributes which compose the primary key. |
|
protected boolean |
isExposePrimaryKeyColumns(org.opengis.feature.simple.SimpleFeatureType featureType)
Returns the expose primary key columns flag for the specified feature type |
|
protected boolean |
isGeneralizationRequired(Hints hints,
org.opengis.feature.type.GeometryDescriptor gatt)
Checks if geometry generalization required and makes sense |
|
protected boolean |
isGenerated(PrimaryKey pkey)
Determines if a primary key is made up entirely of column which are generated via an auto-generating column or a sequence. |
|
protected boolean |
isGeometryReduceRequired(Hints hints,
org.opengis.feature.type.GeometryDescriptor gatt,
Hints.Key param)
Checks if reduction required and makes sense |
|
protected boolean |
isSimplificationRequired(Hints hints,
org.opengis.feature.type.GeometryDescriptor gatt)
Checks if geometry simplification required and makes sense |
|
protected void |
releaseConnection(java.sql.Connection cx,
JDBCState state)
Releases an existing connection. |
|
protected java.lang.String |
selectAggregateSQL(java.lang.String function,
org.opengis.feature.type.AttributeDescriptor att,
org.opengis.feature.simple.SimpleFeatureType featureType,
Query query)
Generates a 'SELECT |
|
protected java.sql.PreparedStatement |
selectAggregateSQLPS(java.lang.String function,
org.opengis.feature.type.AttributeDescriptor att,
org.opengis.feature.simple.SimpleFeatureType featureType,
Query query,
java.sql.Connection cx)
Generates a 'SELECT |
|
protected java.lang.String |
selectAssociationSQL(java.lang.String fid)
Creates the sql for the association table. |
|
protected java.sql.PreparedStatement |
selectAssociationSQLPS(java.lang.String fid,
java.sql.Connection cx)
Creates the prepared statement for the association table. |
|
protected java.lang.String |
selectBoundsSQL(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query)
Generates a 'SELECT' sql statement which selects bounds. |
|
protected java.sql.PreparedStatement |
selectBoundsSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query,
java.sql.Connection cx)
Generates a 'SELECT' prepared statement which selects bounds. |
|
protected java.lang.String |
selectCountSQL(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query)
Generates a 'SELECT count(*) FROM' sql statement. |
|
protected java.sql.PreparedStatement |
selectCountSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query,
java.sql.Connection cx)
Generates a 'SELECT count(*) FROM' prepared statement. |
|
protected java.lang.String |
selectGeometryAssociationSQL(java.lang.String fid,
java.lang.String gid,
java.lang.String gname)
Creates the sql for a select from the geometry association table. |
|
protected java.sql.PreparedStatement |
selectGeometryAssociationSQLPS(java.lang.String fid,
java.lang.String gid,
java.lang.String gname,
java.sql.Connection cx)
Creates the prepared statement for a select from the geometry association table. |
|
protected java.lang.String |
selectGeometrySQL(java.lang.String gid)
Creates the sql for a select from the geometry table. |
|
protected java.sql.PreparedStatement |
selectGeometrySQLPS(java.lang.String gid,
java.sql.Connection cx)
Creates the prepared for a select from the geometry table. |
|
protected java.lang.String |
selectMultiGeometrySQL(java.lang.String gid)
Creates the sql for a select from the multi geometry table. |
|
protected java.sql.PreparedStatement |
selectMultiGeometrySQLPS(java.lang.String gid,
java.sql.Connection cx)
Creates the prepared statement for a select from the multi geometry table. |
|
protected java.lang.String |
selectRelationshipSQL(java.lang.String table,
java.lang.String column)
Creates the sql for the relationship table. |
|
protected java.sql.PreparedStatement |
selectRelationshipSQLPS(java.lang.String table,
java.lang.String column,
java.sql.Connection cx)
Creates the prepared statement for a query against the relationship table. |
|
protected java.lang.String |
selectSQL(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query)
Generates a 'SELECT p1, p2, ... |
|
protected java.sql.PreparedStatement |
selectSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType,
Query query,
java.sql.Connection cx)
Generates a 'SELECT p1, p2, ... |
|
void |
setAssociations(boolean foreignKeyGeometries)
Sets the flag controlling if the datastore is supporting feature and geometry relationships with associations |
|
void |
setDatabaseSchema(java.lang.String databaseSchema)
Set the database schema for the datastore. |
|
void |
setDataSource(javax.sql.DataSource dataSource)
Sets the data source the datastore uses to obtain connections to the underlying database. |
|
void |
setExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns)
Sets the flag controlling if the datastore creates feature types which include those columns / attributes which compose the primary key. |
|
void |
setFetchSize(int fetchSize)
Changes the fetch size. |
|
protected void |
setGmlProperties(com.vividsolutions.jts.geom.Geometry g,
java.lang.String gid,
java.lang.String name,
java.lang.String description)
Helper method for setting the gml:id of a geometry as user data. |
|
protected void |
setPreparedFilterValues(java.sql.PreparedStatement ps,
PreparedFilterToSQL toSQL,
int offset,
java.sql.Connection cx)
Helper method for setting the values of the WHERE class of a prepared statement. |
|
void |
setPrimaryKeyFinder(PrimaryKeyFinder primaryKeyFinder)
Sets the finder used to build PrimaryKey representations |
|
void |
setSQLDialect(SQLDialect dialect)
Sets the dialect the datastore uses to generate sql statements in order to communicate with the underlying database. |
|
protected void |
update(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.feature.type.AttributeDescriptor[] attributes,
java.lang.Object[] values,
org.opengis.filter.Filter filter,
java.sql.Connection cx)
Updates an existing feature(s) in the database for a particular feature type / table. |
|
protected void |
update(org.opengis.feature.simple.SimpleFeatureType featureType,
java.util.List<org.opengis.feature.type.AttributeDescriptor> attributes,
java.util.List<java.lang.Object> values,
org.opengis.filter.Filter filter,
java.sql.Connection cx)
Updates an existing feature(s) in the database for a particular feature type / table. |
|
protected java.lang.String |
updateSQL(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.feature.type.AttributeDescriptor[] attributes,
java.lang.Object[] values,
org.opengis.filter.Filter filter)
Generates an 'UPDATE' sql statement. |
|
protected java.sql.PreparedStatement |
updateSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType,
org.opengis.feature.type.AttributeDescriptor[] attributes,
java.lang.Object[] values,
org.opengis.filter.Filter filter,
java.sql.Connection cx)
Generates an 'UPDATE' prepared statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String JDBC_NATIVE_SRID
public static final java.lang.String JDBC_READ_ONLY
public static final java.lang.String JDBC_NATIVE_TYPENAME
protected static final java.lang.String GEOMETRY_TABLE
associations
is set.
protected static final java.lang.String MULTI_GEOMETRY_TABLE
associations
is set.
protected static final java.lang.String GEOMETRY_ASSOCIATION_TABLE
associations
is set.
protected static final java.lang.String FEATURE_RELATIONSHIP_TABLE
associations
is set.
protected static final java.lang.String FEATURE_ASSOCIATION_TABLE
associations
is set.
protected static final PrimaryKeyFinder DEFAULT_PRIMARY_KEY_FINDER
protected static final ReferencedEnvelope EMPTY_ENVELOPE
protected javax.sql.DataSource dataSource
protected SQLDialect dialect
protected java.lang.String databaseSchema
protected java.util.HashMap<java.lang.Integer,java.lang.Class<?>> sqlTypeToClassMappings
protected java.util.HashMap<java.lang.String,java.lang.Class<?>> sqlTypeNameToClassMappings
protected java.util.HashMap<java.lang.Class<?>,java.lang.Integer> classToSqlTypeMappings
protected java.util.HashMap<java.lang.Integer,java.lang.String> sqlTypeToSqlTypeNameOverrides
protected java.util.HashMap<java.lang.Class<? extends org.opengis.feature.FeatureVisitor>,java.lang.String> aggregateFunctions
protected boolean associations
protected int fetchSize
protected boolean exposePrimaryKeyColumns
protected PrimaryKeyFinder primaryKeyFinder
Constructor Detail |
---|
public JDBCDataStore()
Method Detail |
---|
public PrimaryKeyFinder getPrimaryKeyFinder()
PrimaryKey
representations
public void setPrimaryKeyFinder(PrimaryKeyFinder primaryKeyFinder)
PrimaryKey
representations
primaryKeyFinder
- public int getFetchSize()
public void setFetchSize(int fetchSize)
fetchSize
- public boolean isExposePrimaryKeyColumns()
public void setExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns)
public SQLDialect getSQLDialect()
null
.public void setSQLDialect(SQLDialect dialect)
dialect
- The dialect, never null
.public javax.sql.DataSource getDataSource()
null
.public void setDataSource(javax.sql.DataSource dataSource)
dataSource
- The data source, never null
.public java.lang.String getDatabaseSchema()
null
if non specified.public void setDatabaseSchema(java.lang.String databaseSchema)
When this value is set only those tables which are part of the schema are
served through the datastore. This value can be set to null
to specify no particular schema.
databaseSchema
- The schema, may be null
.public FilterCapabilities getFilterCapabilities()
null
.public boolean isAssociations()
public void setAssociations(boolean foreignKeyGeometries)
public java.util.Map<java.lang.Integer,java.lang.Class<?>> getSqlTypeToClassMappings()
These mappings are derived from SQLDialect.registerSqlTypeToClassMappings(java.util.Map)
null
.public java.util.Map<java.lang.String,java.lang.Class<?>> getSqlTypeNameToClassMappings()
These mappings are derived from SQLDialect.registerSqlTypeNameToClassMappings(Map)
null.
public java.util.Map<java.lang.Class<?>,java.lang.Integer> getClassToSqlTypeMappings()
These mappings are derived from SQLDialect.registerClassToSqlMappings(Map)
null
.public java.util.Map<java.lang.Integer,java.lang.String> getSqlTypeToSqlTypeNameOverrides()
Types
)
to database type names.
This method will return an empty map when there are no overrides.
public java.util.Map<java.lang.Class<? extends org.opengis.feature.FeatureVisitor>,java.lang.String> getAggregateFunctions()
public java.lang.Class<?> getMapping(int sqlType)
If there is no such type mapped to sqlType, null
is returned.
sqlType
- The integer constant for the sql type from Types
.
null
. if no such mapping exists.public java.lang.Class<?> getMapping(java.lang.String sqlTypeName)
If there is no such type mapped to sqlTypeName, null
is returned.
sqlTypeName
- The name of the sql type.
null
. if no such mapping exists.public java.lang.Integer getMapping(java.lang.Class<?> clazz)
If there is no such type mapped to clazz, Types.OTHER
is returned.
clazz
- The java class.
Types
, Types.OTHER if no such
mapping exists.public void createSchema(org.opengis.feature.simple.SimpleFeatureType featureType) throws java.io.IOException
This method will map the classes of the attributes of featureType to sql types and generate a 'CREATE TABLE' statement against the underlying database.
createSchema
in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
createSchema
in class ContentDataStore
featureType
- FetureType to add to DataStore
java.lang.IllegalArgumentException
- If the table already exists.
java.io.IOException
- If the table cannot be created due to an error.DataStore#createSchema(SimpleFeatureType)
public java.lang.Object getGmlObject(org.opengis.filter.identity.GmlObjectId id, Hints hints) throws java.io.IOException
GmlObjectStore
This method returns null
if no such object exists.
getGmlObject
in interface GmlObjectStore
id
- The id of the object, must not be null
.hints
- Any hints to use when looking up the gml object, this value
may be null
.
null
if one could not be found
matching the specified id.
java.io.IOException
- Any I/O errors that occur.protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws java.io.IOException
JDBCFeatureStore
.
createFeatureSource
in class ContentDataStore
entry
- The entry.
ContentFeatureSource
for the entry.
java.io.IOException
ContentDataStore.createFeatureSource(ContentEntry)
protected ContentState createContentState(ContentEntry entry)
JDBCState
.
createContentState
in class ContentDataStore
entry
- The entry.
ContentState
for the entry.ContentDataStore.createContentState(ContentEntry)
protected java.util.List createTypeNames() throws java.io.IOException
The list is generated from the underlying database metadata.
createTypeNames
in class ContentDataStore
Name
.
java.io.IOException
- Any errors occuring connecting to data.protected PrimaryKey getPrimaryKey(ContentEntry entry) throws java.io.IOException
java.io.IOException
protected java.lang.Class getColumnType(java.sql.DatabaseMetaData metaData, java.lang.String databaseSchema2, java.lang.String tableName, java.lang.String columnName) throws java.sql.SQLException
java.sql.SQLException
protected PrimaryKey getPrimaryKey(org.opengis.feature.simple.SimpleFeatureType featureType) throws java.io.IOException
java.io.IOException
protected boolean isExposePrimaryKeyColumns(org.opengis.feature.simple.SimpleFeatureType featureType) throws java.io.IOException
featureType
-
java.io.IOException
protected ReferencedEnvelope getBounds(org.opengis.feature.simple.SimpleFeatureType featureType, Query query, java.sql.Connection cx) throws java.io.IOException
featureType
- The feature type / table.query
- Specifies rows to include in bounds calculation, as well as how many
features and the offset if needed
java.io.IOException
protected int getCount(org.opengis.feature.simple.SimpleFeatureType featureType, Query query, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
protected java.lang.Object getAggregateValue(org.opengis.feature.FeatureVisitor visitor, org.opengis.feature.simple.SimpleFeatureType featureType, Query query, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
protected void insert(org.opengis.feature.simple.SimpleFeature feature, org.opengis.feature.simple.SimpleFeatureType featureType, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
protected void insert(java.util.Collection features, org.opengis.feature.simple.SimpleFeatureType featureType, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
protected void update(org.opengis.feature.simple.SimpleFeatureType featureType, java.util.List<org.opengis.feature.type.AttributeDescriptor> attributes, java.util.List<java.lang.Object> values, org.opengis.filter.Filter filter, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
protected void update(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.feature.type.AttributeDescriptor[] attributes, java.lang.Object[] values, org.opengis.filter.Filter filter, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
protected void delete(org.opengis.feature.simple.SimpleFeatureType featureType, java.lang.String fid, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
protected void delete(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.filter.Filter filter, java.sql.Connection cx) throws java.io.IOException
java.io.IOException
public java.sql.Connection getConnection(Transaction t) throws java.io.IOException
Transaction
. This has two main use cases:
JDBCDataStore
Transaction.AUTO_COMMIT
or if the transaction is not shared
with this data store and originating FeatureStore
objects it is the duty of the
caller to properly close the connection after usage, failure to do so will result in the
connection pool loose one available connection permanentlyTransaction
facilities to do so instead
t
- The GeoTools transaction. Can be null
, in that case a new connection will
be returned (as if Transaction.AUTO_COMMIT
was provided)
java.io.IOException
protected final java.sql.Connection getConnection(JDBCState state) throws java.io.IOException
java.io.IOException
protected final java.sql.Connection createConnection()
Callers of this method should close the connection when done with it.
.
protected final void releaseConnection(java.sql.Connection cx, JDBCState state)
protected java.lang.String encodeFID(PrimaryKey pkey, java.sql.ResultSet rs) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
protected java.lang.String encodeFID(java.util.List<java.lang.Object> keyValues)
protected java.util.List<java.lang.Object> decodeFID(PrimaryKey key, java.lang.String FID, boolean strict)
strict
- If set to true the value of the fid will be validated against
the type of the key columns. If a conversion can not be made, an exception will be thrown.protected boolean isGenerated(PrimaryKey pkey)
protected java.util.List<java.lang.Object> getNextValues(PrimaryKey pkey, java.sql.Connection cx) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
protected java.lang.Object getNextValue(PrimaryKeyColumn col, PrimaryKey pkey, java.sql.Connection cx) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
protected java.util.List<java.lang.Object> getLastValues(PrimaryKey pkey, java.sql.Connection cx) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
protected java.lang.Object getLastValue(PrimaryKeyColumn col, PrimaryKey pkey, java.sql.Connection cx) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
protected java.lang.String createTableSQL(org.opengis.feature.simple.SimpleFeatureType featureType, java.sql.Connection cx) throws java.lang.Exception
java.lang.Exception
protected void ensureAuthorization(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.filter.Filter filter, Transaction tx, java.sql.Connection cx) throws java.io.IOException, java.sql.SQLException
If any features matching the filter are locked, and the transaction does not have authorization with respect to the lock, an exception is thrown.
featureType
- The feature type / table.filter
- The filters.tx
- The transaction.cx
- The database connection.
java.io.IOException
java.sql.SQLException
protected void ensureAssociationTablesExist(java.sql.Connection cx) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
protected java.lang.String createRelationshipTableSQL(java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
java.sql.SQLException
protected java.lang.String createAssociationTableSQL(java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
java.sql.SQLException
protected java.lang.String createGeometryTableSQL(java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
java.sql.SQLException
protected java.lang.String createMultiGeometryTableSQL(java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
java.sql.SQLException
protected java.lang.String selectRelationshipSQL(java.lang.String table, java.lang.String column)
This method is only called when isAssociations()
is true.
table
- The table of the associationcolumn
- The column of the associationprotected java.sql.PreparedStatement selectRelationshipSQLPS(java.lang.String table, java.lang.String column, java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
table
- The table of the associationcolumn
- The column of the association
java.sql.SQLException
protected java.lang.String selectAssociationSQL(java.lang.String fid)
This method is only called when isAssociations()
is true.
fid
- The feature id of the associationprotected java.sql.PreparedStatement selectAssociationSQLPS(java.lang.String fid, java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
fid
- The feature id of the association
java.sql.SQLException
protected java.lang.String selectGeometrySQL(java.lang.String gid)
This method is only called when isAssociations()
is true.
gid
- The geometry id to select for, may be null
protected java.sql.PreparedStatement selectGeometrySQLPS(java.lang.String gid, java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
gid
- The geometry id to select for, may be null
java.sql.SQLException
protected java.lang.String selectMultiGeometrySQL(java.lang.String gid)
This method is only called when isAssociations()
is true.
gid
- The geometry id to select for, may be null
.protected java.sql.PreparedStatement selectMultiGeometrySQLPS(java.lang.String gid, java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
gid
- The geometry id to select for, may be null
.
java.sql.SQLException
protected java.lang.String createGeometryAssociationTableSQL(java.sql.Connection cx) throws java.sql.SQLException
This method is only called when isAssociations()
is true.
java.sql.SQLException
protected java.lang.String selectGeometryAssociationSQL(java.lang.String fid, java.lang.String gid, java.lang.String gname)
fid
- The fid to select for, may be null
gid
- The geometry id to select for, may be null
gname
- The geometry name to select for, may be null
protected java.sql.PreparedStatement selectGeometryAssociationSQLPS(java.lang.String fid, java.lang.String gid, java.lang.String gname, java.sql.Connection cx) throws java.sql.SQLException
fid
- The fid to select for, may be null
gid
- The geometry id to select for, may be null
gname
- The geometry name to select for, may be null
java.sql.SQLException
protected java.lang.String selectSQL(org.opengis.feature.simple.SimpleFeatureType featureType, Query query) throws java.io.IOException
featureType
- the feature type that the query must return (may contain less
attributes than the native one)attributes
- the properties queried, or Query.ALL_NAMES
to gather
all of themquery
- the query to be run. The type name and property will be ignored, as they are
supposed to have been already embedded into the provided feature typesort
- sort conditions
java.io.IOException
protected java.sql.PreparedStatement selectSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType, Query query, java.sql.Connection cx) throws java.sql.SQLException, java.io.IOException
featureType
- the feature type that the query must return (may contain less
attributes than the native one)attributes
- the properties queried, or Query.ALL_NAMES
to gather
all of themquery
- the query to be run. The type name and property will be ignored, as they are
supposed to have been already embedded into the provided feature typecx
- The database connection to be used to create the prepared
statement
java.sql.SQLException
java.io.IOException
protected void setPreparedFilterValues(java.sql.PreparedStatement ps, PreparedFilterToSQL toSQL, int offset, java.sql.Connection cx) throws java.sql.SQLException
java.sql.SQLException
protected java.lang.String getPropertyName(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.filter.expression.PropertyName propertyName)
This method will fall back on PropertyName.getPropertyName()
if
it does not evaulate against the feature type.
protected java.lang.String selectBoundsSQL(org.opengis.feature.simple.SimpleFeatureType featureType, Query query)
featureType
- The feature type / table.query
- Specifies which features are to be used for the bounds computation
(and in particular uses filter, start index and max features)protected java.sql.PreparedStatement selectBoundsSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType, Query query, java.sql.Connection cx) throws java.sql.SQLException
featureType
- The feature type / table.query
- Specifies which features are to be used for the bounds computation
(and in particular uses filter, start index and max features)cx
- A database connection.
java.sql.SQLException
protected java.lang.String selectCountSQL(org.opengis.feature.simple.SimpleFeatureType featureType, Query query)
select *
as limit/offset usually alters the number of returned rows
(and a count returns just one), and then count on the result of that first select
protected java.sql.PreparedStatement selectCountSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType, Query query, java.sql.Connection cx) throws java.sql.SQLException
java.sql.SQLException
protected java.lang.String selectAggregateSQL(java.lang.String function, org.opengis.feature.type.AttributeDescriptor att, org.opengis.feature.simple.SimpleFeatureType featureType, Query query)
protected java.sql.PreparedStatement selectAggregateSQLPS(java.lang.String function, org.opengis.feature.type.AttributeDescriptor att, org.opengis.feature.simple.SimpleFeatureType featureType, Query query, java.sql.Connection cx) throws java.sql.SQLException
java.sql.SQLException
protected void encodeFunction(java.lang.String function, org.opengis.feature.type.AttributeDescriptor att, Query query, java.lang.StringBuffer sql)
protected java.lang.String deleteSQL(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.filter.Filter filter)
protected java.sql.PreparedStatement deleteSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.filter.Filter filter, java.sql.Connection cx) throws java.sql.SQLException
java.sql.SQLException
protected java.lang.String insertSQL(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.feature.simple.SimpleFeature feature, java.util.List keyValues, java.sql.Connection cx)
java.io.IOException
protected java.util.LinkedHashSet<java.lang.String> getColumnNames(PrimaryKey key)
key
- protected java.sql.PreparedStatement insertSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.feature.simple.SimpleFeature feature, java.util.List keyValues, java.sql.Connection cx) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
protected int getGeometrySRID(com.vividsolutions.jts.geom.Geometry g, org.opengis.feature.type.AttributeDescriptor descriptor) throws java.io.IOException
java.io.IOException
protected int getDescriptorSRID(org.opengis.feature.type.AttributeDescriptor descriptor)
descriptor
- protected java.lang.String updateSQL(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.feature.type.AttributeDescriptor[] attributes, java.lang.Object[] values, org.opengis.filter.Filter filter) throws java.io.IOException
java.io.IOException
protected java.sql.PreparedStatement updateSQLPS(org.opengis.feature.simple.SimpleFeatureType featureType, org.opengis.feature.type.AttributeDescriptor[] attributes, java.lang.Object[] values, org.opengis.filter.Filter filter, java.sql.Connection cx) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
protected FilterToSQL createFilterToSQL(org.opengis.feature.simple.SimpleFeatureType featureType)
The featureType may be null but it is not recommended. Such a case where this may neccessary is when a literal needs to be encoded in isolation.
protected PreparedFilterToSQL createPreparedFilterToSQL(org.opengis.feature.simple.SimpleFeatureType featureType)
protected <F extends FilterToSQL> F initializeFilterToSQL(F toSQL, org.opengis.feature.simple.SimpleFeatureType featureType)
protected void encodeTableName(java.lang.String tableName, java.lang.StringBuffer sql)
protected void setGmlProperties(com.vividsolutions.jts.geom.Geometry g, java.lang.String gid, java.lang.String name, java.lang.String description)
public void closeSafe(java.sql.ResultSet rs)
This method closed the result set "safely" in that it never throws an
exception. Any exceptions that do occur are logged at Level.FINER
.
rs
- The result set to close.public void closeSafe(java.sql.Statement st)
This method closed the statement"safely" in that it never throws an
exception. Any exceptions that do occur are logged at Level.FINER
.
st
- The statement to close.public void closeSafe(java.sql.Connection cx)
This method closed the connection "safely" in that it never throws an
exception. Any exceptions that do occur are logged at Level.FINER
.
cx
- The connection to close.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void dispose()
DataAccess
A DataStore
cannot be used after dispose
has
been called, neither can any data access object it helped create, such
as FeatureReader
, FeatureSource
or FeatureCollection
.
This operation can be called more than once without side effects.
There is no thread safety assurance associated with this method. For example, client code will have to make sure this method is not called while retrieving/saving data from/to the storage, or be prepared for the consequences.
dispose
in interface DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
dispose
in class ContentDataStore
protected boolean isGeneralizationRequired(Hints hints, org.opengis.feature.type.GeometryDescriptor gatt)
hints
- hints hints passed ingatt
- Geometry attribute descriptor
protected boolean isSimplificationRequired(Hints hints, org.opengis.feature.type.GeometryDescriptor gatt)
hints
- hints hints passed ingatt
- Geometry attribute descriptor
protected boolean isGeometryReduceRequired(Hints hints, org.opengis.feature.type.GeometryDescriptor gatt, Hints.Key param)
hints
- hints passed ingatt
- Geometry attribute descriptorparam
- Hints.GEOMETRY_GENERALIZATION
or Hints.GEOMETRY_SIMPLIFICATION
protected void encodeGeometryColumn(org.opengis.feature.type.GeometryDescriptor gatt, java.lang.StringBuffer sql, Hints hints)
SQLDialect.addSupportedHints(Set)
gatt
- sql
- hints
- , may be nullpublic Transaction buildTransaction(java.sql.Connection cx)
JDBCDataStore
.
Calls to Transaction.commit()
, Transaction.rollback()
and
Transaction.close()
will not result in corresponding calls to the provided
Connection
object.
conn
- The externally managed connection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |