com.ibm.di.connector
Class JDBCConnector

java.lang.Object
  extended by com.ibm.di.connector.Connector
      extended by com.ibm.di.connector.JDBCConnector
All Implemented Interfaces:
ConnectorInterface, VersionInfoInterface
Direct Known Subclasses:
DBChangelogConnector

public class JDBCConnector
extends Connector
implements ConnectorInterface

This connector provides access to JDBC/ODBC based systems. The connector will attempt to perform as much conversion between types as possible.


Field Summary
 
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
 
Constructor Summary
JDBCConnector()
          Constructor
 
Method Summary
 void alterSession(String command)
          Create a ALTER SESSION Sql statement, and execute it.
 void commit()
          Commit the last transactions
 void deleteEntry(Entry entry, SearchCriteria search)
          Deletes an existing entry.
 String execSQL(String sql)
          Executes an SQL statement.
 String execSQLSelect(String sql)
          Executes an SQL statement, the returned values can be retrieved using getNextSQLSelectEntry()
 Entry findEntry(SearchCriteria search)
          Finds an existing entry.
 Connection getConnection()
          Returns the Connection handle for the currently open session.
 Entry getNextEntry()
          Gets the nextEntry attribute of the JDBCConnector object
 Entry getNextSQLSelectEntry()
          Gets the nextSQLSelectEntry entry
 Statement getStatement()
          Returns the Statement handle for the currently open session
 String getSubClause(SearchCriteria.rscSearch rs, boolean ps)
          Constructs an SQL where expression from an rscSearch class.
 String getVersion()
          Return version information
 String getWhereClause(SearchCriteria search, boolean ps)
          Creates where clause for SQL statement
 void initialize(Object o)
          Initialize the connector and discover syntax
 boolean isDeltaSupported()
          Returns true if this connector is able to perform delta updates
 boolean isIOException(Throwable e)
          Method checks exception type
 void modEntry(Entry entry, SearchCriteria search)
          Modifies an existing entry.
 void putEntry(Entry entry)
          Adds a new entry.
 Object querySchema(Object table)
          Query for schema of table
 Vector queryTables()
          Queries for list Of tables
 void rollback()
          Rollback the last transactions since the last commit
 void saveMetaData(ResultSetMetaData md)
          Saves the Meta Data info
 void selectEntries()
          Prepares for getNextEntry().
 boolean setCommitMode(String mode)
          Set the commit behavior of this JDBC Connector.
 void setCurrent(Entry entry, SearchCriteria search)
          Change the SearchCriteria search to find the entry sent as a parameter.
 void setResultSet(ResultSet rs)
          Instructs this connector to use the provided result set instead of its own.
 void setSessionParameters()
          Sets the sessionParameters attribute of the JDBCConnector object
 String sqlValue(String name, Object value)
           
 void terminate()
          terminate - close handles and connections
 
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, hasConfigValue, hasParser, initParser, isExceptionFatal, logmsg, modEntry, pushback, queryOperations, queryReply, reconnect, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminateServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isExceptionFatal, modEntry, pushback, queryOperations, queryReply, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminateServer
 

Constructor Detail

JDBCConnector

public JDBCConnector()
Constructor

Method Detail

initialize

public void initialize(Object o)
                throws Exception
Initialize the connector and discover syntax

Specified by:
initialize in interface ConnectorInterface
Overrides:
initialize in class Connector
Parameters:
o - Ignored
Throws:
Exception - Throws exception if required JDBC parameters are not set.

setSessionParameters

public void setSessionParameters()
                          throws SQLException
Sets the sessionParameters attribute of the JDBCConnector object

Throws:
SQLException - Contains exception thrown during database operations

alterSession

public void alterSession(String command)
                  throws SQLException
Create a ALTER SESSION Sql statement, and execute it.

Parameters:
command - The rest of the ALTER SESSION statement
Throws:
SQLException - Contains exception thrown during database operations

isDeltaSupported

public boolean isDeltaSupported()
Returns true if this connector is able to perform delta updates

Specified by:
isDeltaSupported in interface ConnectorInterface
Overrides:
isDeltaSupported in class Connector
Returns:
true if delta updates are supported, false otherwise

isIOException

public boolean isIOException(Throwable e)
Method checks exception type

Specified by:
isIOException in interface ConnectorInterface
Overrides:
isIOException in class Connector
Parameters:
e - Exception
Returns:
true if exception of type IOException ,if of type SQLException return false

terminate

public void terminate()
terminate - close handles and connections

Specified by:
terminate in interface ConnectorInterface
Overrides:
terminate in class Connector

selectEntries

public void selectEntries()
                   throws Exception
Prepares for getNextEntry().

Specified by:
selectEntries in interface ConnectorInterface
Overrides:
selectEntries in class Connector
Throws:
Exception - Exception thrown during database operations
See Also:
getNextEntry()

getNextEntry

public Entry getNextEntry()
                   throws Exception
Gets the nextEntry attribute of the JDBCConnector object

Specified by:
getNextEntry in interface ConnectorInterface
Overrides:
getNextEntry in class Connector
Returns:
The nextEntry value
Throws:
Exception - Exception thrown during database operations
See Also:
Connector.selectEntries()

findEntry

public Entry findEntry(SearchCriteria search)
                throws Exception
Finds an existing entry. The search criteria specifies which entry to modify.

Specified by:
findEntry in interface ConnectorInterface
Overrides:
findEntry in class Connector
Parameters:
search - The search criteria used to locate the entry to be modified
Returns:
The entry found, or null if no or multiple entries found
Throws:
Any - exceptions thrown by the connector's underlying classes
Exception - Any exceptions thrown by the connector's underlying classes

modEntry

public void modEntry(Entry entry,
                     SearchCriteria search)
              throws Exception
Modifies an existing entry. The new entry data is given by the entry parameter and the search criteria specifies which entry to modify.

Specified by:
modEntry in interface ConnectorInterface
Overrides:
modEntry in class Connector
Parameters:
entry - The entry data
search - The search criteria used to locate the entry to be modified
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

putEntry

public void putEntry(Entry entry)
              throws Exception
Adds a new entry.

Specified by:
putEntry in interface ConnectorInterface
Overrides:
putEntry in class Connector
Parameters:
entry - The entry object
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

deleteEntry

public void deleteEntry(Entry entry,
                        SearchCriteria search)
                 throws Exception
Deletes an existing entry. The search criteria specifies which entry to modify.

Specified by:
deleteEntry in interface ConnectorInterface
Overrides:
deleteEntry in class Connector
Parameters:
entry - The entry data
search - The search criteria used to locate the entry to be modified
Throws:
Any - exceptions thrown by the connector's underlying classes
Exception - Any exceptions thrown by the connector's underlying classes

execSQL

public String execSQL(String sql)
Executes an SQL statement.

Parameters:
sql - The SQL statement to execute
Returns:
An empty string if no error, otherwise a string describing the error

execSQLSelect

public String execSQLSelect(String sql)
Executes an SQL statement, the returned values can be retrieved using getNextSQLSelectEntry()

Parameters:
sql - The SQL statement to execute
Returns:
An empty string if no error, otherwise a string describing the error

getNextSQLSelectEntry

public Entry getNextSQLSelectEntry()
                            throws Exception
Gets the nextSQLSelectEntry entry

Returns:
The nextSQLSelectEntry value, null if no value available
Throws:
Exception
See Also:
execSQLSelect(java.lang.String)

commit

public void commit()
            throws SQLException
Commit the last transactions

Throws:
SQLException - Thrown if an error occurs

rollback

public void rollback()
              throws SQLException
Rollback the last transactions since the last commit

Throws:
SQLException - Thrown if an error occurs
See Also:
commit(), setCommitMode(java.lang.String)

setCommitMode

public boolean setCommitMode(String mode)
Set the commit behavior of this JDBC Connector.

Parameters:
mode - The intended behavior. Possible values are:
  • "After every database operation"
  • "On Connector close"
  • "Manual"
Returns:
false if the requested mode is not a legal value
See Also:
commit()

queryTables

public Vector queryTables()
                   throws Exception
Queries for list Of tables

Overrides:
queryTables in class Connector
Returns:
Vector List of tables
Throws:
Exception - Thrown if error occurs
See Also:
Vector

querySchema

public Object querySchema(Object table)
                   throws Exception
Query for schema of table

Specified by:
querySchema in interface ConnectorInterface
Overrides:
querySchema in class Connector
Parameters:
table - Entry object
Returns:
MetaData of queried table
Throws:
Exception - Thrown if error occurs
See Also:
Entry, Vector

getStatement

public Statement getStatement()
Returns the Statement handle for the currently open session

Returns:
The statement value

setResultSet

public void setResultSet(ResultSet rs)
                  throws Exception
Instructs this connector to use the provided result set instead of its own.

Parameters:
rs - The new resultSet value
Throws:
Exception - Thrown if error occurs

getConnection

public Connection getConnection()
Returns the Connection handle for the currently open session.

Returns:
The connection value

getWhereClause

public String getWhereClause(SearchCriteria search,
                             boolean ps)
                      throws Exception
Creates where clause for SQL statement

Parameters:
search - SearchCriteria
ps - Boolean which determines if is a prepared statement.
Returns:
sql SQL string with where clause
Throws:
Exception - Thrown if error occurs

getSubClause

public String getSubClause(SearchCriteria.rscSearch rs,
                           boolean ps)
                    throws Exception
Constructs an SQL where expression from an rscSearch class.

Returns:
The SQL where expression
Throws:
Exception

sqlValue

public String sqlValue(String name,
                       Object value)

saveMetaData

public void saveMetaData(ResultSetMetaData md)
                  throws SQLException
Saves the Meta Data info

Parameters:
md - ResultSetMetaData
Throws:
SQLException - Thrown if there is an error

setCurrent

public void setCurrent(Entry entry,
                       SearchCriteria search)
Description copied from class: Connector
Change the SearchCriteria search to find the entry sent as a parameter. Used when multiple entries found, and you want to modify or delete one of them. Only a few connectors need to implement this.

Specified by:
setCurrent in interface ConnectorInterface
Overrides:
setCurrent in class Connector
Parameters:
entry - The entry we want to find for modification/delete
search - The SearchCriteria we want to change

getVersion

public String getVersion()
Return version information

Specified by:
getVersion in interface VersionInfoInterface
Returns:
The version value