Package com.ziclix.python.sql
Class Jython22DataHandler
java.lang.Object
com.ziclix.python.sql.DataHandler
com.ziclix.python.sql.Jython22DataHandler
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 -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of datahandlers chained together through the use of delegation.getMetaDataName(PyObject name) Some database vendors are case sensitive on calls to DatabaseMetaData, most notably Oracle.getProcedure(PyCursor cursor, PyObject name) A factory method for determing the correct procedure class to use per the cursor type.getPyObject(CallableStatement stmt, int col, int type) Given a CallableStatement, column and type, return the appropriate Jython object.getPyObject(ResultSet set, int col, int type) Given a ResultSet, column and type, return the appropriate Jython object.Returns the row id of the last executed statement.voidpostExecute(Statement stmt) A callback after successfully executing the statement.voidpreExecute(Statement stmt) A callback prior to each execution of the statement.voidregisterOut(CallableStatement statement, int index, int colType, int dataType, String dataTypeName) Called when a stored procedure or function is executed and OUT parameters need to be registered with the statement.voidsetJDBCObject(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.voidsetJDBCObject(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
-
Constructor Details
-
Jython22DataHandler
public Jython22DataHandler()Handle most generic Java data types.
-
-
Method Details
-
getMetaDataName
Some database vendors are case sensitive on calls to DatabaseMetaData, most notably Oracle. This callback allows a DataHandler to affect the name.- Overrides:
getMetaDataNamein classDataHandler
-
getProcedure
A factory method for determing the correct procedure class to use per the cursor type.- Overrides:
getProcedurein classDataHandler- Parameters:
cursor- an open cursorname- the name of the procedure to invoke- Returns:
- an instance of a Procedure
- Throws:
SQLException
-
getRowId
Returns the row id of the last executed statement.- Overrides:
getRowIdin classDataHandler- Parameters:
stmt- the current statement- Returns:
- the row id of the last executed statement or None
- Throws:
SQLException- thrown if an exception occurs
-
preExecute
A callback prior to each execution of the statement. If the statement is a PreparedStatement, all the parameters will have been set.- Overrides:
preExecutein classDataHandler- Throws:
SQLException
-
postExecute
A callback after successfully executing the statement.- Overrides:
postExecutein classDataHandler- Throws:
SQLException
-
setJDBCObject
Any .execute() which uses prepared statements will receive a callback for deciding how to map the PyObject to the appropriate JDBC type.- Overrides:
setJDBCObjectin classDataHandler- Parameters:
stmt- the current PreparedStatementindex- the index for which this object is boundobject- the PyObject in question- Throws:
SQLException
-
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.- Overrides:
setJDBCObjectin classDataHandler- Parameters:
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- Throws:
SQLException
-
getPyObject
Given a ResultSet, column and type, return the appropriate Jython object.Note: DO NOT iterate the ResultSet.
- Overrides:
getPyObjectin classDataHandler- Parameters:
set- the current ResultSet set to the current rowcol- the column number (adjusted properly for JDBC)type- the column type- Throws:
SQLException- if the type is unmappable
-
getPyObject
Given a CallableStatement, column and type, return the appropriate Jython object.- Overrides:
getPyObjectin classDataHandler- Parameters:
stmt- the CallableStatementcol- the column number (adjusted properly for JDBC)type- the column type- Throws:
SQLException- if the type is unmappable
-
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.- Overrides:
registerOutin classDataHandler- Parameters:
statement-index- the JDBC offset column numbercolType- the column as from DatabaseMetaData (eg, procedureColumnOut)dataType- the JDBC datatype from TypesdataTypeName- the JDBC datatype name- Throws:
SQLException
-
__chain__
Returns a list of datahandlers chained together through the use of delegation.- Overrides:
__chain__in classDataHandler- Returns:
- a list of datahandlers
-