From: brian z. <bz...@us...> - 2001-12-10 03:37:43
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql In directory usw-pr-cvs1:/tmp/cvs-serv22641/ziclix/python/sql Modified Files: PyConnection.java PyCursor.java PyExtendedCursor.java Log Message: added cursor.connection Index: PyConnection.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/PyConnection.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyConnection.java 2001/11/27 10:48:04 1.2 --- PyConnection.java 2001/12/10 03:37:40 1.3 *************** *** 211,215 **** * */ ! void rollback() { if (!this.supportsTransactions) { --- 211,215 ---- * */ ! public void rollback() { if (!this.supportsTransactions) { *************** *** 232,236 **** */ public PyCursor cursor() { ! return new PyExtendedCursor(this.connection); } --- 232,236 ---- */ public PyCursor cursor() { ! return new PyExtendedCursor(this); } *************** *** 244,248 **** */ public PyCursor cursor(boolean dynamicFetch) { ! return new PyExtendedCursor(this.connection, dynamicFetch); } } --- 244,248 ---- */ public PyCursor cursor(boolean dynamicFetch) { ! return new PyExtendedCursor(this, dynamicFetch); } } Index: PyCursor.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/PyCursor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyCursor.java 2001/12/08 15:44:29 1.7 --- PyCursor.java 2001/12/10 03:37:40 1.8 *************** *** 43,47 **** /** Field connection */ ! protected Connection connection; /** Field datahandler */ --- 43,47 ---- /** Field connection */ ! protected PyConnection connection; /** Field datahandler */ *************** *** 66,70 **** * Create the cursor with a static fetch. */ ! PyCursor(Connection connection) { this(connection, false); } --- 66,70 ---- * Create the cursor with a static fetch. */ ! PyCursor(PyConnection connection) { this(connection, false); } *************** *** 74,78 **** * If dynamicFetch is true, then use a dynamic fetch. */ ! PyCursor(Connection connection, boolean dynamicFetch) { this.arraysize = 1; --- 74,78 ---- * If dynamicFetch is true, then use a dynamic fetch. */ ! PyCursor(PyConnection connection, boolean dynamicFetch) { this.arraysize = 1; *************** *** 177,180 **** --- 177,182 ---- } else if ("dynamic".equals(name)) { return this.dynamicFetch ? Py.One : Py.Zero; + } else if ("connection".equals(name)) { + return this.connection; } *************** *** 204,208 **** dict.__setitem__("classDictInit", null); dict.__setitem__("toString", null); - dict.__setitem__("connection", null); dict.__setitem__("getDataHandler", null); dict.__setitem__("addWarning", null); --- 206,209 ---- *************** *** 234,237 **** --- 235,248 ---- /** + * Return ths DatabaseMetaData for the current connection. + * + * @return DatabaseMetaData + * + */ + protected DatabaseMetaData getMetaData() throws SQLException { + return this.connection.connection.getMetaData(); + } + + /** * Return the currently bound DataHandler. */ *************** *** 254,273 **** /** - * Prepare a callable statement (stored procedure). - * - * @param sqlString - * @param maxRows max number of rows to be returned - * @throws SQLException - */ - protected void callableStatement(String sqlString, PyObject maxRows) throws SQLException { - - this.sqlStatement = this.connection.prepareCall(sqlString); - - if (maxRows != Py.None) { - this.sqlStatement.setMaxRows(maxRows.__int__().getValue()); - } - } - - /** * Prepare a statement ready for executing. * --- 265,268 ---- *************** *** 280,286 **** if (prepared) { ! this.sqlStatement = this.connection.prepareStatement(sqlString); } else { ! this.sqlStatement = this.connection.createStatement(); } --- 275,281 ---- if (prepared) { ! this.sqlStatement = this.connection.connection.prepareStatement(sqlString); } else { ! this.sqlStatement = this.connection.connection.createStatement(); } *************** *** 306,311 **** try { ! if (this.connection.getMetaData().supportsStoredProcedures()) { ! callableStatement(sqlString, maxRows); execute(params, bindings); } else { --- 301,311 ---- try { ! if (getMetaData().supportsStoredProcedures()) { ! this.sqlStatement = this.connection.connection.prepareCall(sqlString); ! ! if (maxRows != Py.None) { ! this.sqlStatement.setMaxRows(maxRows.__int__().getValue()); ! } ! execute(params, bindings); } else { Index: PyExtendedCursor.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/PyExtendedCursor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyExtendedCursor.java 2001/12/07 02:56:39 1.3 --- PyExtendedCursor.java 2001/12/10 03:37:40 1.4 *************** *** 61,68 **** * Constructor PyExtendedCursor * ! * @param Connection connection * */ ! PyExtendedCursor(Connection connection) { super(connection); } --- 61,68 ---- * Constructor PyExtendedCursor * ! * @param PyConnection connection * */ ! PyExtendedCursor(PyConnection connection) { super(connection); } *************** *** 71,79 **** * Constructor PyExtendedCursor * ! * @param Connection connection * @param boolean dynamicFetch * */ ! PyExtendedCursor(Connection connection, boolean dynamicFetch) { super(connection, dynamicFetch); } --- 71,79 ---- * Constructor PyExtendedCursor * ! * @param PyConnection connection * @param boolean dynamicFetch * */ ! PyExtendedCursor(PyConnection connection, boolean dynamicFetch) { super(connection, dynamicFetch); } *************** *** 147,151 **** try { ! create(this.connection.getMetaData().getTables(q, o, t, y)); } catch (SQLException e) { throw zxJDBC.newError(e); --- 147,151 ---- try { ! create(getMetaData().getTables(q, o, t, y)); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 171,175 **** try { ! create(this.connection.getMetaData().getColumns(q, o, t, c)); } catch (SQLException e) { throw zxJDBC.newError(e); --- 171,175 ---- try { ! create(getMetaData().getColumns(q, o, t, c)); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 193,197 **** try { ! create(this.connection.getMetaData().getProcedures(q, o, p)); } catch (SQLException e) { throw zxJDBC.newError(e); --- 193,197 ---- try { ! create(getMetaData().getProcedures(q, o, p)); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 217,221 **** try { ! create(this.connection.getMetaData().getProcedureColumns(q, o, p, c)); } catch (SQLException e) { throw zxJDBC.newError(e); --- 217,221 ---- try { ! create(getMetaData().getProcedureColumns(q, o, p, c)); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 240,244 **** try { ! create(this.connection.getMetaData().getPrimaryKeys(q, o, t)); } catch (SQLException e) { throw zxJDBC.newError(e); --- 240,244 ---- try { ! create(getMetaData().getPrimaryKeys(q, o, t)); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 273,277 **** try { ! create(this.connection.getMetaData().getCrossReference(pq, po, pt, fq, fo, ft)); } catch (SQLException e) { throw zxJDBC.newError(e); --- 273,277 ---- try { ! create(getMetaData().getCrossReference(pq, po, pt, fq, fo, ft)); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 304,308 **** try { ! create(this.connection.getMetaData().getIndexInfo(q, o, t, u, a), skipCols); } catch (SQLException e) { throw zxJDBC.newError(e); --- 304,308 ---- try { ! create(getMetaData().getIndexInfo(q, o, t, u, a), skipCols); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 325,329 **** try { ! create(this.connection.getMetaData().getTypeInfo(), skipCols); } catch (SQLException e) { throw zxJDBC.newError(e); --- 325,329 ---- try { ! create(getMetaData().getTypeInfo(), skipCols); } catch (SQLException e) { throw zxJDBC.newError(e); *************** *** 353,357 **** try { ! create(this.connection.getMetaData().getTableTypes()); } catch (SQLException e) { throw zxJDBC.newError(e); --- 353,357 ---- try { ! create(getMetaData().getTableTypes()); } catch (SQLException e) { throw zxJDBC.newError(e); |