Exemplo n.º 1
0
  /** Provide functionality for Oracle specific types, such as ROWID. */
  public PyObject getPyObject(ResultSet set, int col, int type) throws SQLException {

    PyObject obj = Py.None;

    switch (type) {
      case Types.BLOB:
        BLOB blob = ((OracleResultSet) set).getBLOB(col);

        if (blob == null) {
          return Py.None;
        }

        InputStream stream = new BufferedInputStream(blob.getBinaryStream());

        obj = Py.java2py(DataHandler.read(stream));
        break;

      case OracleTypes.ROWID:
        ROWID rowid = ((OracleResultSet) set).getROWID(col);

        if (rowid != null) {
          obj = Py.java2py(rowid.stringValue());
        }
        break;

      default:
        obj = super.getPyObject(set, col, type);
    }

    return (set.wasNull() ? Py.None : obj);
  }
Exemplo n.º 2
0
  /** Provide functionality for Oracle specific types, such as ROWID. */
  public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type)
      throws SQLException {

    if (DataHandler.checkNull(stmt, index, object, type)) {
      return;
    }

    switch (type) {
      case OracleTypes.ROWID:
        stmt.setString(index, (String) object.__tojava__(String.class));
        break;

      case Types.DECIMAL:

        // Oracle is annoying
        Object input = object.__tojava__(Double.class);

        if (input != Py.NoConversion) {
          stmt.setDouble(index, ((Double) input).doubleValue());

          break;
        }

        super.setJDBCObject(stmt, index, object, type);
        break;

      case Types.NUMERIC:
        super.setJDBCObject(stmt, index, object, Types.DOUBLE);
        break;

      case Types.BLOB:
      case Types.CLOB:
        Integer[] vals = {new Integer(index), new Integer(type)};
        String msg = zxJDBC.getString("errorSettingIndex", vals);

        throw new SQLException(msg);
      default:
        super.setJDBCObject(stmt, index, object, type);
    }
  }