Jython22DataHandler (Jython API documentation)
Date: 2022-09-10

com.ziclix.python.sql

## Class Jython22DataHandler

- java.lang.Object
- - com.ziclix.python.sql.DataHandler
  - - com.ziclix.python.sql.Jython22DataHandler

-     public class Jython22DataHandler
      extends DataHandler

  A copy of the DataHandler class as it was before Jython 2.5. By that version, some backward-incompatible changes was made, as returning datetime.* objects for DATE, TIME and TIMESTAMP columns, instead of java.sql.* classes.
  Author:
    brian zimmer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Jython22DataHandler()` Handle most generic Java data types.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `PyObject` | `__chain__()` Returns a list of datahandlers chained together through the use of delegation.
    `java.lang.String` | `getMetaDataName(PyObject name)` Some database vendors are case sensitive on calls to DatabaseMetaData, most notably Oracle.
    `Procedure` | `getProcedure(PyCursor cursor, PyObject name)` A factory method for determing the correct procedure class to use per the cursor type.
    `PyObject` | `getPyObject(java.sql.CallableStatement stmt, int col, int type)` Given a CallableStatement, column and type, return the appropriate Jython object.
    `PyObject` | `getPyObject(java.sql.ResultSet set, int col, int type)` Given a ResultSet, column and type, return the appropriate Jython object.
    `PyObject` | `getRowId(java.sql.Statement stmt)` Returns the row id of the last executed statement.
    `void` | `postExecute(java.sql.Statement stmt)` A callback after successfully executing the statement.
    `void` | `preExecute(java.sql.Statement stmt)` A callback prior to each execution of the statement.
    `void` | `registerOut(java.sql.CallableStatement statement, int index, int colType, int dataType, java.lang.String dataTypeName)` Called when a stored procedure or function is executed and OUT parameters need to be registered with the statement.
    `void` | `setJDBCObject(java.sql.PreparedStatement stmt, int index, PyObject object)` Any .execute() which uses prepared statements will receive a callback for deciding how to map the PyObject to the appropriate JDBC type.
    `void` | `setJDBCObject(java.sql.PreparedStatement stmt, int index, PyObject object, int type)` Any .execute() which uses prepared statements will receive a callback for deciding how to map the PyObject to the appropriate JDBC type.

    - ### Methods inherited from class com.ziclix.python.sql.DataHandler

      `checkNull, getSystemDataHandler, read, read, toString`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Jython22DataHandler

          public Jython22DataHandler()

      Handle most generic Java data types.

  - ### Method Detail

    - #### getMetaDataName

          public java.lang.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.
      Overrides:
        `getMetaDataName` in class `DataHandler`

    - #### getProcedure

          public Procedure getProcedure(PyCursor cursor,
                                        PyObject name)
                                 throws java.sql.SQLException

      A factory method for determing the correct procedure class to use per the cursor type.
      Overrides:
        `getProcedure` in class `DataHandler`
      Parameters:
        `cursor` - an open cursor
        `name` - the name of the procedure to invoke
      Returns:
        an instance of a Procedure
      Throws:
        `java.sql.SQLException`

    - #### getRowId

          public PyObject getRowId(java.sql.Statement stmt)
                            throws java.sql.SQLException

      Returns the row id of the last executed statement.
      Overrides:
        `getRowId` in class `DataHandler`
      Parameters:
        `stmt` - the current statement
      Returns:
        the row id of the last executed statement or None
      Throws:
        `java.sql.SQLException` - thrown if an exception occurs

    - #### preExecute

          public void preExecute(java.sql.Statement stmt)
                          throws java.sql.SQLException

      A callback prior to each execution of the statement. If the statement is a PreparedStatement, all the parameters will have been set.
      Overrides:
        `preExecute` in class `DataHandler`
      Throws:
        `java.sql.SQLException`

    - #### postExecute

          public void postExecute(java.sql.Statement stmt)
                           throws java.sql.SQLException

      A callback after successfully executing the statement.
      Overrides:
        `postExecute` in class `DataHandler`
      Throws:
        `java.sql.SQLException`

    - #### setJDBCObject

          public void setJDBCObject(java.sql.PreparedStatement stmt,
                                    int index,
                                    PyObject object)
                             throws java.sql.SQLException

      Any .execute() which uses prepared statements will receive a callback for deciding how to map the PyObject to the appropriate JDBC type.
      Overrides:
        `setJDBCObject` in class `DataHandler`
      Parameters:
        `stmt` - the current PreparedStatement
        `index` - the index for which this object is bound
        `object` - the PyObject in question
      Throws:
        `java.sql.SQLException`

    - #### setJDBCObject

          public void setJDBCObject(java.sql.PreparedStatement stmt,
                                    int index,
                                    PyObject object,
                                    int type)
                             throws java.sql.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.
      Overrides:
        `setJDBCObject` in class `DataHandler`
      Parameters:
        `stmt` - the current PreparedStatement
        `index` - the index for which this object is bound
        `object` - the PyObject in question
        `type` - the java.sql.Types for which this PyObject should be bound
      Throws:
        `java.sql.SQLException`

    - #### getPyObject

          public PyObject getPyObject(java.sql.ResultSet set,
                                      int col,
                                      int type)
                               throws java.sql.SQLException

      Given a ResultSet, column and type, return the appropriate Jython object.

      Note: DO NOT iterate the ResultSet.

      Overrides:
        `getPyObject` in class `DataHandler`
      Parameters:
        `set` - the current ResultSet set to the current row
        `col` - the column number (adjusted properly for JDBC)
        `type` - the column type
      Throws:
        `java.sql.SQLException` - if the type is unmappable

    - #### getPyObject

          public PyObject getPyObject(java.sql.CallableStatement stmt,
                                      int col,
                                      int type)
                               throws java.sql.SQLException

      Given a CallableStatement, column and type, return the appropriate Jython object.
      Overrides:
        `getPyObject` in class `DataHandler`
      Parameters:
        `stmt` - the CallableStatement
        `col` - the column number (adjusted properly for JDBC)
        `type` - the column type
      Throws:
        `java.sql.SQLException` - if the type is unmappable

    - #### registerOut

          public void registerOut(java.sql.CallableStatement statement,
                                  int index,
                                  int colType,
                                  int dataType,
                                  java.lang.String dataTypeName)
                           throws java.sql.SQLException

      Called when a stored procedure or function is executed and OUT parameters need to be registered with the statement.
      Overrides:
        `registerOut` in class `DataHandler`
      Parameters:
        `statement` -
        `index` - the JDBC offset column number
        `colType` - the column as from DatabaseMetaData (eg, procedureColumnOut)
        `dataType` - the JDBC datatype from Types
        `dataTypeName` - the JDBC datatype name
      Throws:
        `java.sql.SQLException`

    - #### __chain__

          public PyObject __chain__()

      Returns a list of datahandlers chained together through the use of delegation.
      Overrides:
        `__chain__` in class `DataHandler`
      Returns:
        a list of datahandlers

Jython homepage