org.geotools.data.geometryless
Class JDBCDataStore

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.geometryless.JDBCDataStore
All Implemented Interfaces:
DataStore
Direct Known Subclasses:
BBOXDataStore, LocationsXYDataStore

public class JDBCDataStore
extends JDBCDataStore

An implementation of the GeoTools Data Store API for a generic non-spatial database platform. The plan is to support traditional jdbc datatypes, and support geometry held within such types (eg, x,y columns, or possibly WKT strings)

Please see class JDBCDataStore and interface DataStore for DataStore usage details.

Author:
Rob Atkinson rob@socialchange.net.au

Field Summary
static java.lang.String DEFAULT_NAMESPACE
          DEFAULT_NAMESPACE field
 
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
JDBCDataStore(ConnectionPool connectionPool)
          Basic constructor for JDBCDataStore.
JDBCDataStore(ConnectionPool connectionPool, java.lang.String databaseSchemaName)
          Constructor for JDBCDataStore where the database schema name is provided.
JDBCDataStore(ConnectionPool connectionPool, java.lang.String databaseSchemaName, java.lang.String namespace)
          Constructor for JDBCDataStore where the database schema name is provided.
 
Method Summary
protected  AttributeType buildAttributeType(java.sql.ResultSet rs)
          Constructs an AttributeType from a row in a ResultSet.
protected  JDBCFeatureWriter createFeatureWriter(FeatureReader reader, QueryData queryData)
           
 FeatureWriter getFeatureWriter(java.lang.String typeName)
          Utility method for getting a FeatureWriter for modifying existing features, using no feature filtering and auto-committing.
 FeatureWriter getFeatureWriterAppend(java.lang.String typeName)
          Utility method for getting a FeatureWriter for adding new features, using auto-committing.
protected  AttributeIO getGeometryAttributeIO(AttributeType type, QueryData queryData)
          Hook to create the geometry attribute IO for a vendor specific data source.
 SQLBuilder getSqlBuilder(java.lang.String typeName)
          Hook for subclass to return a different sql builder.
 
Methods inherited from class org.geotools.data.jdbc.JDBC2DataStore
createConnection
 
Methods inherited from class org.geotools.data.jdbc.JDBC1DataStore
allowTable, allSameOrder, attributeNames, buildFIDMapperFactory, buildSchema, createFeatureReader, createLockingManager, createSchema, determineFidColumnName, determineSRID, executeQuery, getAttributeIO, getAttributeTypes, getConcurrency, getConnection, getEnvelope, getFeatureReader, getFeatureReader, getFeatureSource, getFeatureTypeHandler, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getFIDMapper, getFIDMapperFactory, getJDBCFeatureReader, getLockingManager, getNameSpace, getResultSetType, getSchema, getSqlNameEscape, getTypeNames, getView, setAutoCommit, setFIDMapper, setFIDMapperFactory, setSqlNameEscape, updateSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE

public static java.lang.String DEFAULT_NAMESPACE
DEFAULT_NAMESPACE field

Constructor Detail

JDBCDataStore

public JDBCDataStore(ConnectionPool connectionPool)
              throws java.io.IOException
Basic constructor for JDBCDataStore. Requires creation of a ConnectionPool, which could be done similar to the following:

MySQLConnectionFactory connectionFactory = new MySQLConnectionFactory("mysqldb.geotools.org", "3306", "myCoolSchema");
ConnectionPool connectionPool = connectionFactory.getConnectionPool("omcnoleg", "myTrickyPassword123");
DataStore dataStore = new JDBCDataStore(connectionPool);

Parameters:
connectionPool - a MySQL ConnectionPool
Throws:
java.io.IOException - if the database cannot be properly accessed
See Also:
ConnectionPool, MySQLConnectionFactory

JDBCDataStore

public JDBCDataStore(ConnectionPool connectionPool,
                     java.lang.String databaseSchemaName)
              throws java.io.IOException
Constructor for JDBCDataStore where the database schema name is provided.

Parameters:
connectionPool - a MySQL ConnectionPool
databaseSchemaName - the database schema. Can be null. See the comments for the parameter schemaPattern in DatabaseMetaData.getTables, because databaseSchemaName behaves in the same way.
Throws:
java.io.IOException - if the database cannot be properly accessed

JDBCDataStore

public JDBCDataStore(ConnectionPool connectionPool,
                     java.lang.String databaseSchemaName,
                     java.lang.String namespace)
              throws java.io.IOException
Constructor for JDBCDataStore where the database schema name is provided.

Parameters:
connectionPool - a MySQL ConnectionPool
databaseSchemaName - the database schema. Can be null. See the comments for the parameter schemaPattern in DatabaseMetaData.getTables, because databaseSchemaName behaves in the same way.
namespace - the namespace for this data store. Can be null, in which case the namespace will simply be the schema name.
Throws:
java.io.IOException - if the database cannot be properly accessed
Method Detail

getFeatureWriter

public FeatureWriter getFeatureWriter(java.lang.String typeName)
                               throws java.io.IOException
Utility method for getting a FeatureWriter for modifying existing features, using no feature filtering and auto-committing. Not used for adding new features.

Parameters:
typeName - the feature type name (the table name)
Returns:
a FeatureWriter for modifying existing features
Throws:
java.io.IOException - if the database cannot be properly accessed

getFeatureWriterAppend

public FeatureWriter getFeatureWriterAppend(java.lang.String typeName)
                                     throws java.io.IOException
Utility method for getting a FeatureWriter for adding new features, using auto-committing. Not used for modifying existing features.

Parameters:
typeName - the feature type name (the table name)
Returns:
a FeatureWriter for adding new features
Throws:
java.io.IOException - if the database cannot be properly accessed

buildAttributeType

protected AttributeType buildAttributeType(java.sql.ResultSet rs)
                                    throws java.io.IOException
Constructs an AttributeType from a row in a ResultSet. The ResultSet contains the information retrieved by a call to getColumns() on the DatabaseMetaData object. This information can be used to construct an Attribute Type.

In addition to standard SQL types, this method identifies MySQL 4.1's geometric datatypes and creates attribute types accordingly. This happens when the datatype, identified by column 5 of the ResultSet parameter, is equal to java.sql.Types.OTHER. If a Types.OTHER ends up not being geometric, this method simply calls the parent class's buildAttributeType method to do something with it.

Note: Overriding methods must never move the current row pointer in the result set.

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.sql.SQLException - If an error occurs processing the ResultSet.
DataSourceException - Provided for overriding classes to wrap exceptions caused by other operations they may perform to determine additional types. This will only be thrown by the default implementation if a type is present that is not present in the TYPE_MAPPINGS.
java.io.IOException - If an error occurs processing the ResultSet.

getSqlBuilder

public SQLBuilder getSqlBuilder(java.lang.String typeName)
                         throws java.io.IOException
Description copied from class: JDBC1DataStore
Hook for subclass to return a different sql builder.

Overrides:
getSqlBuilder in class JDBC1DataStore
Parameters:
typeName - The typename for the sql builder.
Returns:
A new sql builder.
Throws:
java.io.IOException - if anything goes wrong.

getGeometryAttributeIO

protected AttributeIO getGeometryAttributeIO(AttributeType type,
                                             QueryData queryData)
Description copied from class: JDBC1DataStore
Hook to create the geometry attribute IO for a vendor specific data source.

Specified by:
getGeometryAttributeIO in class JDBC1DataStore
Parameters:
type - The AttributeType to read.
queryData - The connection holder
Returns:
The AttributeIO that will read and write the geometry from the results.
See Also:
org.geotools.data.jdbc.JDBCDataStore#getGeometryAttributeIO(org.geotools.feature.AttributeType)

createFeatureWriter

protected JDBCFeatureWriter createFeatureWriter(FeatureReader reader,
                                                QueryData queryData)
                                         throws java.io.IOException
Overrides:
createFeatureWriter in class JDBC1DataStore
Throws:
java.io.IOException


Copyright © GeoTools. All Rights Reserved.