public void run() { boolean eof = false; JavaCharStream stream = new JavaCharStream(in, 1, 1); exec("_ps1 = sys.ps1"); PyObject ps1Obj = get("_ps1"); String ps1 = ps1Obj.toString(); exec("_ps2 = sys.ps2"); PyObject ps2Obj = get("_ps2"); String ps2 = ps2Obj.toString(); out.print(getDefaultBanner() + "\n"); out.print(ps1); String line = ""; while (!eof) { // try to sync up the console System.out.flush(); System.err.flush(); Thread.yield(); // this helps a little try { boolean eol = false; line = ""; while (!eol) { char aChar = stream.readChar(); eol = (aChar == '\n'); if (!eol) line = line + aChar; } // hitting Enter at prompt returns a semicolon // get rid of it since it returns an error when executed if (line.equals(";")) line = ""; { boolean retVal = push(line); if (retVal) { out.print(ps2); } else { out.print(ps1); } } } catch (IOException ex) { } } }
/** 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); } }