From: brian z. <bz...@us...> - 2001-12-29 07:16:23
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql/handler In directory usw-pr-cvs1:/tmp/cvs-serv2506/ziclix/python/sql/handler Modified Files: OracleDataHandler.java Added Files: SQLServerDataHandler.java Log Message: stored procedure changes --- NEW FILE: SQLServerDataHandler.java --- /* * Jython Database Specification API 2.0 * * $Id: SQLServerDataHandler.java,v 1.1 2001/12/29 07:16:20 bzimmer Exp $ * * Copyright (c) 2001 brian zimmer <bz...@zi...> * */ package com.ziclix.python.sql.handler; import java.io.*; import java.sql.*; import java.math.*; import org.python.core.*; import com.ziclix.python.sql.*; /** * SQLServer specific data handling. * * @author brian zimmer * @author last revised by $Author: bzimmer $ * @version $Revision: 1.1 $ */ public class SQLServerDataHandler extends FilterDataHandler { /** Field UNICODE_VARCHAR */ public static final int UNICODE_VARCHAR = -9; /** * Decorator for handling SQLServer specific issues. * * @param datahandler the delegate DataHandler */ public SQLServerDataHandler(DataHandler datahandler) { super(datahandler); } /** * Given a ResultSet, column and type, return the appropriate * Jython object. * * <p>Note: DO NOT iterate the ResultSet. * * @param set the current ResultSet set to the current row * @param col the column number (adjusted properly for JDBC) * @param type the column type * @throws SQLException if the type is unmappable */ public PyObject getPyObject(ResultSet set, int col, int type) throws SQLException { PyObject obj = Py.None; switch (type) { case UNICODE_VARCHAR : obj = super.getPyObject(set, col, Types.VARCHAR); break; default : obj = super.getPyObject(set, col, type); } return (set.wasNull() || (obj == null)) ? Py.None : obj; } /** * Method getProcedureName * * @param PyObject catalog * @param PyObject schema * @param PyObject name * * @return String * */ public String getProcedureName(PyObject catalog, PyObject schema, PyObject name) { StringBuffer procName = new StringBuffer(); if ((schema != Py.EmptyString) && (schema != Py.None)) { procName.append(schema.toString()).append("."); } return procName.append(name.toString()).toString(); } } Index: OracleDataHandler.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/handler/OracleDataHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OracleDataHandler.java 2001/12/14 04:19:27 1.3 --- OracleDataHandler.java 2001/12/29 07:16:20 1.4 *************** *** 132,134 **** --- 132,164 ---- return (set.wasNull() ? Py.None : obj); } + + /** + * Called when a stored procedure or function is executed and OUT parameters + * need to be registered with the statement. + * + * @param CallableStatement statement + * @param int index the JDBC offset column number + * @param int colType the column as from DatabaseMetaData (eg, procedureColumnOut) + * @param int dataType the JDBC datatype from Types + * @param String dataTypeName the JDBC datatype name + * + * @throws SQLException + * + */ + public void registerOut(CallableStatement statement, int index, int colType, int dataType, String dataTypeName) throws SQLException { + + if (dataType == Types.OTHER) { + if ("REF CURSOR".equals(dataTypeName)) { + statement.registerOutParameter(index, OracleTypes.CURSOR); + + return; + } else if ("PL/SQL RECORD".equals(dataTypeName)) { + statement.registerOutParameter(index, OracleTypes.CURSOR); + + return; + } + } + + super.registerOut(statement, index, colType, dataType, dataTypeName); + } } |