/** * Prepares the statement and registers the OUT/INOUT parameters (if any). * * @param rsType the value of to be created ResultSet type * @param rsConcur the value of the to be created ResultSet concurrency * @return CallableStatement * @throws SQLException */ public CallableStatement prepareCall(PyObject rsType, PyObject rsConcur) throws SQLException { // prepare the statement CallableStatement statement = null; boolean normal = ((rsType == Py.None) && (rsConcur == Py.None)); try { // build the full call syntax String sqlString = toSql(); if (normal) { statement = cursor.connection.connection.prepareCall(sqlString); } else { int t = rsType.asInt(); int c = rsConcur.asInt(); statement = cursor.connection.connection.prepareCall(sqlString, t, c); } // prepare the OUT parameters registerOutParameters(statement); } catch (SQLException e) { if (statement != null) { try { statement.close(); } catch (Exception ex) { } } throw e; } return statement; }
int get_int(PyObject value) { try { return value.asInt(); } catch (PyException ex) { throw StructError("required argument is not an integer"); } }
public int __len__() { PyType self_type = getType(); PyObject impl = self_type.lookup("__len__"); if (impl != null) { PyObject res = impl.__get__(this, self_type).__call__(); return res.asInt(); } return super.__len__(); }
public int __cmp__(PyObject other) { PyType self_type = getType(); PyObject[] where_type = new PyObject[1]; PyObject impl = self_type.lookup_where("__cmp__", where_type); // Full Compatibility with CPython __cmp__: // If the derived type don't override __cmp__, the // *internal* super().__cmp__ should be called, not the // exposed one. The difference is that the exposed __cmp__ // throws a TypeError if the argument is an instance of the same type. if (impl == null || where_type[0] == TYPE || Py.isSubClass(TYPE, where_type[0])) { return super.__cmp__(other); } PyObject res = impl.__get__(this, self_type).__call__(other); if (res == Py.NotImplemented) { return -2; } int c = res.asInt(); return c < 0 ? -1 : c > 0 ? 1 : 0; }