org.geotools.data.db2
Class DB2DataStoreFactory

Object
  extended by AbstractDataStoreFactory
      extended by DB2DataStoreFactory
All Implemented Interfaces:
DataAccessFactory, 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
Module:
modules/plugin/db2 (gt-db2.jar)

Nested Class Summary
 
Nested classes/interfaces inherited from interface DataAccessFactory
DataAccessFactory.Param
 
Field Summary
static DataAccessFactory.Param DATABASE
           
static DataAccessFactory.Param DBTYPE
           
static String DRIVERNAME
           
static DataAccessFactory.Param HOST
           
static DataAccessFactory.Param MAXCONN
           
static DataAccessFactory.Param MINCONN
           
static DataAccessFactory.Param PASSWD
           
static DataAccessFactory.Param PORT
           
static DataAccessFactory.Param TABSCHEMA
           
static DataAccessFactory.Param USER
           
static DataAccessFactory.Param VALIDATECONN
           
 
Constructor Summary
DB2DataStoreFactory()
           
 
Method Summary
 boolean canProcess(Map params)
          Check whether the parameter list passed identifies it as a request for a DB2DataStore.
 DataStore createDataStore(Map params)
          Constructs a DB2 data store using the params.
 DataStore createNewDataStore(Map params)
          Creating a new DB2 database is not supported.
static ManageableDataSource getDefaultDataSource(String url, String user, String passwd, int maxActive, int minIdle, boolean validate)
           
 String getDescription()
          Provide a String description of this data store.
 String getDisplayName()
          Name suitable for display to end user.
static String getJDBCUrl(String host, int port, String database)
          Returns the JDBC url used for connecting to a specific database
 DataAccessFactory.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 AbstractDataStoreFactory
getImplementationHints, getParameters
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Factory
getImplementationHints
 

Field Detail

DRIVERNAME

public static final String DRIVERNAME
See Also:
Constant Field Values

DBTYPE

public static final DataAccessFactory.Param DBTYPE

HOST

public static final DataAccessFactory.Param HOST

PORT

public static final DataAccessFactory.Param PORT

DATABASE

public static final DataAccessFactory.Param DATABASE

USER

public static final DataAccessFactory.Param USER

PASSWD

public static final DataAccessFactory.Param PASSWD

TABSCHEMA

public static final DataAccessFactory.Param TABSCHEMA

MAXCONN

public static final DataAccessFactory.Param MAXCONN

MINCONN

public static final DataAccessFactory.Param MINCONN

VALIDATECONN

public static final DataAccessFactory.Param VALIDATECONN
Constructor Detail

DB2DataStoreFactory

public DB2DataStoreFactory()
Method Detail

createDataStore

public DataStore createDataStore(Map params)
                          throws IOException
Constructs a DB2 data store using the params. If the port number is zero we will try to use the JDBC type 2 driver and if the port number is non-zer, we will try to use the JDBC type 4 driver

Specified by:
createDataStore in interface DataAccessFactory
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:
IOException - See DataSourceException
DataSourceException - Thrown if there were any problems creating or connecting the datasource.

getDefaultDataSource

public static ManageableDataSource getDefaultDataSource(String url,
                                                        String user,
                                                        String passwd,
                                                        int maxActive,
                                                        int minIdle,
                                                        boolean validate)
                                                 throws DataSourceException
Throws:
DataSourceException

getJDBCUrl

public static String getJDBCUrl(String host,
                                int port,
                                String database)
Returns the JDBC url used for connecting to a specific database


createNewDataStore

public DataStore createNewDataStore(Map params)
                             throws 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:
UnsupportedOperationException - Cannot create new database

getDescription

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

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

getDisplayName

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

A non localized display name for this data store type.

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

getParametersInfo

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

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

canProcess

public boolean canProcess(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 DataAccessFactory
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 DataAccessFactory
Overrides:
isAvailable in class AbstractDataStoreFactory
Returns:
true if a DB2 driver is available for the DB2DataStore to connect to a DB2 database.


Copyright © 1996-2010 Geotools. All Rights Reserved.