org.geotools.data.db2
Class DB2DataStoreFactory

java.lang.Object
  extended byorg.geotools.data.AbstractDataStoreFactory
      extended byorg.geotools.data.db2.DB2DataStoreFactory
All Implemented Interfaces:
DataStoreFactorySpi, Factory

public class DB2DataStoreFactory
extends AbstractDataStoreFactory
implements DataStoreFactorySpi

Implements the DataStoreFactorySpi interface to create an instance of a DB2DataStore.

Author:
David Adler - IBM Corporation

Nested Class Summary
 
Nested classes inherited from class org.geotools.data.DataStoreFactorySpi
DataStoreFactorySpi.Param
 
Constructor Summary
DB2DataStoreFactory()
           
 
Method Summary
 boolean canProcess(java.util.Map params)
          Check whether the parameter list passed identifies it as a request for a DB2DataStore.
 DataStore createDataStore(java.util.Map params)
          Constructs a DB2 data store using the params.
 DataStore createNewDataStore(java.util.Map params)
          Creating a new DB2 database is not supported.
 java.lang.String getDescription()
          Provide a String description of this data store.
 java.lang.String getDisplayName()
          Name suitable for display to end user.
 DataStoreFactorySpi.Param[] getParametersInfo()
          Returns the array of parameters used by DB2.
 boolean isAvailable()
          Check whether the DB2 JDBC type 4 driver is found in the classpath.
 
Methods inherited from class org.geotools.data.AbstractDataStoreFactory
getImplementationHints, getParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.factory.Factory
getImplementationHints
 

Constructor Detail

DB2DataStoreFactory

public DB2DataStoreFactory()
Method Detail

createDataStore

public DataStore createDataStore(java.util.Map params)
                          throws java.io.IOException
Constructs a DB2 data store using the params.

Specified by:
createDataStore in interface DataStoreFactorySpi
Parameters:
params - The full set of information needed to construct a live data source. Should have dbtype equal to DB2, as well as host, user, passwd, database, and table schema.
Returns:
The created DataSource, this may be null if the required resource was not found or if insufficent parameters were given. Note that canProcess() should have returned false if the problem is to do with insuficent parameters.
Throws:
java.io.IOException - See DataSourceException
DataSourceException - Thrown if there were any problems creating or connecting the datasource.

createNewDataStore

public DataStore createNewDataStore(java.util.Map params)
                             throws java.lang.UnsupportedOperationException
Creating a new DB2 database is not supported.

Specified by:
createNewDataStore in interface DataStoreFactorySpi
Parameters:
params - Doesn't much matter what this contains.
Returns:
DataStore But will always throw an exception
Throws:
java.lang.UnsupportedOperationException - Cannot create new database

getDescription

public java.lang.String getDescription()
Provide a String description of this data store.

Specified by:
getDescription in interface DataStoreFactorySpi
Returns:
the data store description.

getDisplayName

public java.lang.String getDisplayName()
Name suitable for display to end user.

A non localized display name for this data store type.

Specified by:
getDisplayName in interface DataStoreFactorySpi
Overrides:
getDisplayName in class AbstractDataStoreFactory
Returns:
A short name suitable for display in a user interface.

getParametersInfo

public DataStoreFactorySpi.Param[] getParametersInfo()
Returns the array of parameters used by DB2.

Specified by:
getParametersInfo in interface DataStoreFactorySpi
Returns:
Param[] Array of parameters.

canProcess

public boolean canProcess(java.util.Map params)
Check whether the parameter list passed identifies it as a request for a DB2DataStore.

Most critical is the 'dbtype' parameter which must have the value 'DB2'. If it is, then the remaining parameter values can be checked.

Specified by:
canProcess in interface DataStoreFactorySpi
Overrides:
canProcess in class AbstractDataStoreFactory
Parameters:
params - Key/Value parameter list containing values required to identify a request for a DB2DataStore and remaining values to identify the database to be connected to.
Returns:
true if dbtype equals DB2, and contains keys for host, user, passwd, and database.

isAvailable

public boolean isAvailable()
Check whether the DB2 JDBC type 4 driver is found in the classpath.

If it isn't, there is a problem since the FactoryFinder found the DB2DataStoreFactory but there is no driver to connect to a DB2 database.

The classpath should have db2jcc.jar and db2jcc_license_cu.jar

Specified by:
isAvailable in interface DataStoreFactorySpi
Overrides:
isAvailable in class AbstractDataStoreFactory
Returns:
true if a DB2 driver is available for the DB2DataStore to connect to a DB2 database.


Copyright © GeoTools. All Rights Reserved.