org.geotools.data.db2
Class DB2DataStore

java.lang.Object
  extended byorg.geotools.data.jdbc.JDBC1DataStore
      extended byorg.geotools.data.jdbc.JDBC2DataStore
          extended byorg.geotools.data.jdbc.JDBCDataStore
              extended byorg.geotools.data.db2.DB2DataStore
All Implemented Interfaces:
DataStore

public class DB2DataStore
extends JDBCDataStore

DB2 DataStore implementation.

Instances of this class should only be obtained via DB2DataStoreFactory.createDataStore or DataStoreFinder.getDataStore.

Author:
David Adler - IBM Corporation

Field Summary
 
Fields inherited from class org.geotools.data.jdbc.JDBC2DataStore
connectionPool
 
Fields inherited from class org.geotools.data.jdbc.JDBC1DataStore
allowWriteOnVolatileFIDs, config, listenerManager, sqlNameEscape, TYPE_MAPPINGS, typeHandler
 
Constructor Summary
DB2DataStore(ConnectionPool connectionPool, JDBCDataStoreConfig config, java.lang.String dbURL)
          The only supported constructor for a DB2DataStore.
 
Method Summary
protected  AttributeType buildAttributeType(java.sql.ResultSet rs)
          Handles DB2-specific geometry types.
protected  FIDMapperFactory buildFIDMapperFactory(JDBCDataStoreConfig config)
          Creates a DB2-specific FIDMapperFactory.
protected  JDBCFeatureWriter createFeatureWriter(FeatureReader featureReader, QueryData queryData)
          Overrides the method in JDBCDataStore so that a DB2FeatureWriter is created.
protected  int determineSRID(java.lang.String tableName, java.lang.String geometryColumnName)
          Get the SRID associated with a geometry column.
protected  QueryData executeQuery(FeatureTypeInfo featureTypeInfo, java.lang.String tableName, java.lang.String sqlQuery, Transaction transaction, boolean forWrite)
          Overrides the method in JDBCDataStore because it includes PostGIS-specific handling to setAutoCommit(false) which causes problems for DB2 because the transaction is still uncommitted when the connection is closed.
 FeatureSource getFeatureSource(java.lang.String typeName)
          Gets a DB2-specific feature source.
protected  FeatureTypeHandler getFeatureTypeHandler(JDBCDataStoreConfig config)
          Create a DB2-specific FeatureTypeHandler.
protected  AttributeIO getGeometryAttributeIO(AttributeType type, QueryData queryData)
          Gets the handler to convert a geometry database value to a JTS geometry.
 SQLBuilder getSqlBuilder(java.lang.String typeName)
          Gets the DB2-specific SQL builder object.
 java.lang.String getTableSchema()
          Gets the table schema associated with this data store.
 java.lang.String[] getTypeNames()
          Gets the names of tables (types) that contain a spatial column.
 
Methods inherited from class org.geotools.data.jdbc.JDBC2DataStore
createConnection
 
Methods inherited from class org.geotools.data.jdbc.JDBC1DataStore
allowTable, allSameOrder, attributeNames, buildSchema, createFeatureReader, createLockingManager, createSchema, determineFidColumnName, getAttributeIO, getAttributeTypes, getConcurrency, getConnection, getEnvelope, getFeatureReader, getFeatureReader, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getFIDMapper, getFIDMapperFactory, getJDBCFeatureReader, getLockingManager, getNameSpace, getResultSetType, getSchema, getSqlNameEscape, getView, setAutoCommit, setFIDMapper, setFIDMapperFactory, setSqlNameEscape, updateSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB2DataStore

public DB2DataStore(ConnectionPool connectionPool,
                    JDBCDataStoreConfig config,
                    java.lang.String dbURL)
             throws java.io.IOException
The only supported constructor for a DB2DataStore. This constructor is mainly intended to be called from DB2DataStoreFactory.

Parameters:
connectionPool - the initialized DB2 connection pool
config - the JDBCDataStoreConfiguration
dbURL - the database URL of the form jdbc:db2://hostname:hostport/dbname
Throws:
java.io.IOException
Method Detail

buildAttributeType

protected AttributeType buildAttributeType(java.sql.ResultSet rs)
                                    throws java.io.IOException
Handles DB2-specific geometry types. If it isn't one, just let the parent method handle it.

Overrides:
buildAttributeType in class JDBC1DataStore
Parameters:
rs - The ResultSet containing the result of a DatabaseMetaData.getColumns call.
Returns:
The AttributeType built from the ResultSet.
Throws:
java.io.IOException - If an error occurs processing the ResultSet.

buildFIDMapperFactory

protected FIDMapperFactory buildFIDMapperFactory(JDBCDataStoreConfig config)
Creates a DB2-specific FIDMapperFactory.

Overrides:
buildFIDMapperFactory in class JDBC1DataStore
Parameters:
config - not used.
Returns:
a DB2FIDMapperFactory

determineSRID

protected int determineSRID(java.lang.String tableName,
                            java.lang.String geometryColumnName)
                     throws java.io.IOException
Get the SRID associated with a geometry column.

The value returned is the EPSG coordinate system identifier, not the DB2 srs_id.

Overrides:
determineSRID in class JDBC1DataStore
Parameters:
tableName - The name of the table to get the SRID for.
geometryColumnName - The name of the geometry column within the table to get SRID for.
Returns:
The SRID for the geometry column or -1.
Throws:
java.io.IOException

getFeatureTypeHandler

protected FeatureTypeHandler getFeatureTypeHandler(JDBCDataStoreConfig config)
                                            throws java.io.IOException
Create a DB2-specific FeatureTypeHandler.

Overrides:
getFeatureTypeHandler in class JDBC1DataStore
Parameters:
config - a JDBCDataStoreConfig.
Returns:
a DB2FeatureTypeHandler.
Throws:
java.io.IOException - if the feature type handler could not be created.

getGeometryAttributeIO

protected AttributeIO getGeometryAttributeIO(AttributeType type,
                                             QueryData queryData)
Gets the handler to convert a geometry database value to a JTS geometry.

Specified by:
getGeometryAttributeIO in class JDBC1DataStore
Parameters:
type - not used.
queryData - not used.
Returns:
AttributIO

getSqlBuilder

public SQLBuilder getSqlBuilder(java.lang.String typeName)
                         throws java.io.IOException
Gets the DB2-specific SQL builder object.

Overrides:
getSqlBuilder in class JDBC1DataStore
Parameters:
typeName - Name of the type to build the SQL for.
Returns:
DB2SQLBuilder
Throws:
java.io.IOException

getTypeNames

public java.lang.String[] getTypeNames()
                                throws java.io.IOException
Gets the names of tables (types) that contain a spatial column. Note that there is still an issue concerning the ambiguity of spatial tables that have the same table name but different table schema names.

Specified by:
getTypeNames in interface DataStore
Overrides:
getTypeNames in class JDBC1DataStore
Returns:
Array of type names as Strings.
Throws:
java.io.IOException - if the spatial catalog can not be accessed.
See Also:
org.geotools.data.DataStore#getFeatureTypes()

getTableSchema

public java.lang.String getTableSchema()
Gets the table schema associated with this data store.

At some point this may change if multiple schemas are supported by a data store.

Returns:
the schema name that will prefix table names.

getFeatureSource

public FeatureSource getFeatureSource(java.lang.String typeName)
                               throws java.io.IOException
Gets a DB2-specific feature source.

Specified by:
getFeatureSource in interface DataStore
Overrides:
getFeatureSource in class JDBC1DataStore
Parameters:
typeName -
Returns:
a DB2Feature Source, Store or Locking
Throws:
java.io.IOException - if the feature source could not be created.
See Also:
DataStore.getFeatureSource(java.lang.String)

executeQuery

protected QueryData executeQuery(FeatureTypeInfo featureTypeInfo,
                                 java.lang.String tableName,
                                 java.lang.String sqlQuery,
                                 Transaction transaction,
                                 boolean forWrite)
                          throws java.io.IOException
Overrides the method in JDBCDataStore because it includes PostGIS-specific handling to setAutoCommit(false) which causes problems for DB2 because the transaction is still uncommitted when the connection is closed.

Overrides:
executeQuery in class JDBC1DataStore
Parameters:
featureTypeInfo -
tableName -
sqlQuery - The SQL query to execute.
transaction - The Transaction is included here for handling transaction connections at a later stage. It is not currently used.
forWrite -
Returns:
The QueryData object that contains the resources for the query.
Throws:
java.io.IOException
DataSourceException - If an error occurs performing the query.

createFeatureWriter

protected JDBCFeatureWriter createFeatureWriter(FeatureReader featureReader,
                                                QueryData queryData)
                                         throws java.io.IOException
Overrides the method in JDBCDataStore so that a DB2FeatureWriter is created.

Overrides:
createFeatureWriter in class JDBC1DataStore
Parameters:
featureReader -
queryData -
Returns:
The DB2FeatureWriter
Throws:
java.io.IOException
See Also:
JDBC1DataStore.createFeatureWriter(org.geotools.data.FeatureReader, org.geotools.data.jdbc.QueryData)


Copyright © GeoTools. All Rights Reserved.