gistoolkit.datasources.db2spatialextender
Class DB2JoinDataSource

java.lang.Object
  extended bygistoolkit.datasources.SimpleDataSource
      extended bygistoolkit.datasources.SimpleJoinDataSource
          extended bygistoolkit.datasources.SimpleJoinDBDataSource
              extended bygistoolkit.datasources.db2spatialextender.DB2JoinDataSource
All Implemented Interfaces:
DataSource

public class DB2JoinDataSource
extends SimpleJoinDBDataSource

Class to join a DB2 Datatable to another data source. Why would you do this? Because it may be more efficient to read shapes from a shape file layer which can cache then on the server, and do the join in this layer. This will prevent the rereading of the shapes from the database each time that the values are needed. Reading the shapes from a shape file in most cases, is much faster than reading them from DB2. This may change with version 8 of the db2 spatial extender. To use this class, first create the data source used to read the shapes. This data source may be of any type, and can read the shapes from any of the data sources. Then create the DB2JoinDataSource with the source data source as it's source. This data source will need to know which attributes it should join on Set the column from the source data that is to be used with the setDatasourceJoinColumn method, and set the column for this data source with the setTableJoinColumn method. The data source will loop through the records returned. The data source first reads the data from the source datasource, then it compares the data from the join data source to that of the source data source, and throws away any that do not have a match. It also trims the source data source to the envelope. This results in a standard inner join between the source data, and the join data.


Field Summary
protected  java.sql.Connection myCon
          Connection to the DB2 datasource used for maintaining persistent connections.
 java.lang.String myDatabaseName
          The name of the database on the DB2 server to connect to.
protected  java.sql.Statement myStmt
          Statment used to maintain distributed transactions.
 
Fields inherited from class gistoolkit.datasources.SimpleDataSource
 
Constructor Summary
DB2JoinDataSource()
          For use with configuration only where the source data source is to be set with the setNode() function.
DB2JoinDataSource(DataSource inSourceDataSource)
          Create a new DB2JoinDataSource with this data source as the source node.
 
Method Summary
 void connect()
          Initializes the connection to the database.
 java.lang.String getDatabaseDriver()
          Returns the jdbc driver class used for connection to the database.
 java.lang.String getDatabaseName()
          Returns the name of the DB2 Database.
 java.lang.String getDatabasePassword()
          Returns the password to use when connecting to the DB2 server.
 int getDatabasePort()
          Returns the tcpip port to use when connecting to the DB2 server
 java.lang.String getDatabaseQuery()
          SQL Query to use in retrieving data from the database.
 java.lang.String getDatabaseSchema()
          Returns the name of the schema within the DB2 database where the data resides.
 java.lang.String getDatabaseServername()
          Returns the computer name of the DB2 server.
 java.lang.String getDatabaseURLBase()
          Returns the url base to use when connecting through the JDBC driver.
 java.lang.String getDatabaseUsername()
          Returns the username to use when connecting to the DB2 server.
 java.lang.String getName()
          Return the name of this datasource for display to the user.
 Node getNode()
          Get the configuration information for this data source
 SQLConverter getSQLConverter()
          Returns the converter for this Database.
 Style getStyle()
          Get the style to use with this datasource.
 GISDataset readShapes(Envelope inEnvelope)
          Reads the objects from the database that fall within the given Envelope.
 void setDatabaseDriver(java.lang.String inDatabaseDriver)
          Sets the name of the jdbc driver class used for connection to the database.
 void setDatabaseName(java.lang.String inDatabaseName)
          Sets the name of the DB2 Database.
 void setDatabasePassword(java.lang.String inDatabasePassword)
          Sets the password to use when connecting to the DB2 server.
 void setDatabasePort(int inDatabasePort)
          Sets the tcpip port to use when connecting to the DB2 server
 void setDatabaseQuery(java.lang.String inQuery)
          SQL Query to use to retrieve data from the database.
 void setDatabaseSchema(java.lang.String inDatabaseSchema)
          Sets the name of the schema within the DB2 database where the data resides.
 void setDatabaseServername(java.lang.String inDatabaseServername)
          Sets the name of the DB2 Server computer.
 void setDatabaseURLBase(java.lang.String inDatabaseURLBase)
          Sets the url base to use when connecting through the JDBC driver.
 void setDatabaseUsername(java.lang.String inDatabaseUsername)
          Sets the username to use when connecting to the DB2 server.
 void setName(java.lang.String inName)
          Set the name of this datasource for display purposes.
 void setNode(Node inNode)
          Set the configuration information for this data source
 
Methods inherited from class gistoolkit.datasources.SimpleJoinDBDataSource
getFilter, getFilterSQL, setFilter
 
Methods inherited from class gistoolkit.datasources.SimpleJoinDataSource
getDatasourceJoinColumn, getDatasourceRecord, getJoinDataSource, getJoinDataSourceAttributeNames, getJoinDataSourceAttributeTypes, getJoinedDataCached, getTableJoinColumn, readDataSource, readEnvelope, setDatasourceJoinColumn, setJoinedDataCached, setTableJoinColumn
 
Methods inherited from class gistoolkit.datasources.SimpleDataSource
addDataSourceListener, clearCache, commit, delete, doCommit, doDelete, doInsert, doRollback, doUpdate, filterDataset, fireCommit, fireDelete, fireInsert, fireRead, fireRollBack, fireUpdate, getCached, getCacheDataset, getCacheEnvelope, getEnvelope, getFromProjection, getToProjection, getValidShapeTypes, insert, isCachedProjected, isUpdateable, projectBackward, projectForward, queryFromCache, readDataset, readDataset, removeDataSourceListener, rollback, setCache, setCached, setFromProjection, setProjection, setToProjection, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myDatabaseName

public java.lang.String myDatabaseName
The name of the database on the DB2 server to connect to.


myCon

protected java.sql.Connection myCon
Connection to the DB2 datasource used for maintaining persistent connections.


myStmt

protected java.sql.Statement myStmt
Statment used to maintain distributed transactions.

Constructor Detail

DB2JoinDataSource

public DB2JoinDataSource()
For use with configuration only where the source data source is to be set with the setNode() function.


DB2JoinDataSource

public DB2JoinDataSource(DataSource inSourceDataSource)
Create a new DB2JoinDataSource with this data source as the source node.

Method Detail

getName

public java.lang.String getName()
Return the name of this datasource for display to the user.

Specified by:
getName in interface DataSource
Overrides:
getName in class SimpleDataSource

setName

public void setName(java.lang.String inName)
Set the name of this datasource for display purposes.

Specified by:
setName in interface DataSource
Overrides:
setName in class SimpleDataSource

getDatabaseURLBase

public java.lang.String getDatabaseURLBase()
Returns the url base to use when connecting through the JDBC driver.


setDatabaseURLBase

public void setDatabaseURLBase(java.lang.String inDatabaseURLBase)
Sets the url base to use when connecting through the JDBC driver.


getDatabaseDriver

public java.lang.String getDatabaseDriver()
Returns the jdbc driver class used for connection to the database.


setDatabaseDriver

public void setDatabaseDriver(java.lang.String inDatabaseDriver)
Sets the name of the jdbc driver class used for connection to the database.


getDatabaseServername

public java.lang.String getDatabaseServername()
Returns the computer name of the DB2 server.


setDatabaseServername

public void setDatabaseServername(java.lang.String inDatabaseServername)
Sets the name of the DB2 Server computer.


getDatabaseName

public java.lang.String getDatabaseName()
Returns the name of the DB2 Database.


setDatabaseName

public void setDatabaseName(java.lang.String inDatabaseName)
Sets the name of the DB2 Database.


getDatabaseSchema

public java.lang.String getDatabaseSchema()
Returns the name of the schema within the DB2 database where the data resides.


setDatabaseSchema

public void setDatabaseSchema(java.lang.String inDatabaseSchema)
Sets the name of the schema within the DB2 database where the data resides.


getDatabaseUsername

public java.lang.String getDatabaseUsername()
Returns the username to use when connecting to the DB2 server.


setDatabaseUsername

public void setDatabaseUsername(java.lang.String inDatabaseUsername)
Sets the username to use when connecting to the DB2 server.


getDatabasePassword

public java.lang.String getDatabasePassword()
Returns the password to use when connecting to the DB2 server.


setDatabasePassword

public void setDatabasePassword(java.lang.String inDatabasePassword)
Sets the password to use when connecting to the DB2 server.


getDatabasePort

public int getDatabasePort()
Returns the tcpip port to use when connecting to the DB2 server


setDatabasePort

public void setDatabasePort(int inDatabasePort)
Sets the tcpip port to use when connecting to the DB2 server


setDatabaseQuery

public void setDatabaseQuery(java.lang.String inQuery)
SQL Query to use to retrieve data from the database.


getDatabaseQuery

public java.lang.String getDatabaseQuery()
SQL Query to use in retrieving data from the database.


connect

public void connect()
             throws java.lang.Exception
Initializes the connection to the database.

Throws:
java.lang.Exception

getSQLConverter

public SQLConverter getSQLConverter()
Returns the converter for this Database.

Overrides:
getSQLConverter in class SimpleJoinDBDataSource

readShapes

public GISDataset readShapes(Envelope inEnvelope)
                      throws java.lang.Exception
Reads the objects from the database that fall within the given Envelope. If a null is sent in for the Envelope, all the objects in the shape file are read.

Specified by:
readShapes in class SimpleJoinDataSource
Throws:
java.lang.Exception

getNode

public Node getNode()
Get the configuration information for this data source

Specified by:
getNode in interface DataSource
Overrides:
getNode in class SimpleJoinDataSource

setNode

public void setNode(Node inNode)
             throws java.lang.Exception
Set the configuration information for this data source

Specified by:
setNode in interface DataSource
Overrides:
setNode in class SimpleJoinDataSource
Throws:
java.lang.Exception

getStyle

public Style getStyle()
Get the style to use with this datasource.

Specified by:
getStyle in interface DataSource
Overrides:
getStyle in class SimpleDataSource