The DataHandler is responsible mapping the JDBC data type to
a Jython object. Depending on the version of the JDBC
implementation and the particulars of the driver, the type
mapping can be significantly different.
This interface can also be used to change the behaviour of
the default mappings provided by the cursor. This might be
useful in handling more complicated data types such as BLOBs,
CLOBs and Arrays.
__chain__
public PyObject __chain__()
Returns a list of datahandlers chained together through the use of delegation.
checkNull
public static final boolean checkNull(PreparedStatement stmt,
int index,
PyObject object,
int type)
throws SQLException
Handles checking if the object is null or None and setting it on the statement.
- true if the object is null and was set on the statement, false otherwise
getMetaDataName
public String getMetaDataName(PyObject name)
Some database vendors are case sensitive on calls to DatabaseMetaData,
most notably Oracle. This callback allows a DataHandler to affect the
name.
getProcedure
public Procedure getProcedure(PyCursor cursor,
PyObject name)
throws SQLException
A factory method for determing the correct procedure class to use
per the cursor type.
cursor
- an open cursorname
- the name of the procedure to invoke
- an instance of a Procedure
getPyObject
public PyObject getPyObject(CallableStatement stmt,
int col,
int type)
throws SQLException
Given a CallableStatement, column and type, return the appropriate
Jython object.
stmt
- the CallableStatementcol
- the column number (adjusted properly for JDBC)type
- the column type
getPyObject
public PyObject getPyObject(ResultSet set,
int col,
int type)
throws SQLException
Given a ResultSet, column and type, return the appropriate
Jython object.
Note: DO NOT iterate the ResultSet.
set
- the current ResultSet set to the current rowcol
- the column number (adjusted properly for JDBC)type
- the column type
getRowId
public PyObject getRowId(Statement stmt)
throws SQLException
Returns the row id of the last executed statement.
stmt
- the current statement
- the row id of the last executed statement or None
getSystemDataHandler
public static final DataHandler getSystemDataHandler()
Build the DataHandler chain depending on the VM. This guarentees a DataHandler
but might additionally chain a JDBC2.0 or JDBC3.0 implementation.
- a DataHandler configured for the VM version
postExecute
public void postExecute(Statement stmt)
throws SQLException
A callback after successfully executing the statement.
preExecute
public void preExecute(Statement stmt)
throws SQLException
A callback prior to each execution of the statement. If the statement is
a PreparedStatement, all the parameters will have been set.
read
public static final byte[] read(InputStream stream)
Since the driver needs to the know the length of all streams,
read it into a byte[] array.
read
public static final String read(Reader reader)
Read all the chars from the Reader into the String.
- the contents of the Reader in a String
registerOut
public void registerOut(CallableStatement statement,
int index,
int colType,
int dataType,
String dataTypeName)
throws SQLException
Called when a stored procedure or function is executed and OUT parameters
need to be registered with the statement.
statement
- index
- the JDBC offset column numbercolType
- the column as from DatabaseMetaData (eg, procedureColumnOut)dataType
- the JDBC datatype from TypesdataTypeName
- the JDBC datatype name
setJDBCObject
public void setJDBCObject(PreparedStatement stmt,
int index,
PyObject object)
throws SQLException
Any .execute() which uses prepared statements will receive a callback for deciding
how to map the PyObject to the appropriate JDBC type.
stmt
- the current PreparedStatementindex
- the index for which this object is boundobject
- the PyObject in question
setJDBCObject
public void setJDBCObject(PreparedStatement stmt,
int index,
PyObject object,
int type)
throws SQLException
Any .execute() which uses prepared statements will receive a callback for deciding
how to map the PyObject to the appropriate JDBC type. The type is the JDBC
type as obtained from java.sql.Types.
stmt
- the current PreparedStatementindex
- the index for which this object is boundobject
- the PyObject in questiontype
- the java.sql.Types for which this PyObject should be bound
toString
public String toString()
Returns the classname of this datahandler.