From: <pj...@us...> - 2009-07-21 01:00:36
|
Revision: 6553 http://jython.svn.sourceforge.net/jython/?rev=6553&view=rev Author: pjenvey Date: 2009-07-21 01:00:16 +0000 (Tue, 21 Jul 2009) Log Message: ----------- ensure all DBAPI cursor functions throw a "cursor is closed" exception when appropriate Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/PyCursor.java Modified: trunk/jython/src/com/ziclix/python/sql/PyCursor.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2009-07-21 00:56:33 UTC (rev 6552) +++ trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2009-07-21 01:00:16 UTC (rev 6553) @@ -634,6 +634,7 @@ * @return a single sequence from the result set, or None when no more data is available */ public PyObject fetchone() { + ensureOpen(); return this.fetch.fetchone(); } @@ -649,6 +650,7 @@ * no more data is available */ public PyObject fetchall() { + ensureOpen(); return this.fetch.fetchall(); } @@ -676,6 +678,7 @@ * no more data is available */ public PyObject fetchmany(int size) { + ensureOpen(); return this.fetch.fetchmany(size); } @@ -685,6 +688,7 @@ * @return true if more sets exist, else None */ public PyObject nextset() { + ensureOpen(); return this.fetch.nextset(); } @@ -728,6 +732,7 @@ * */ public void scroll(int value, String mode) { + ensureOpen(); this.fetch.scroll(value, mode); } @@ -763,9 +768,7 @@ * */ protected void clear() { - if (closed) { - throw zxJDBC.makeException(zxJDBC.ProgrammingError, "cursor is closed"); - } + ensureOpen(); this.warnings = Py.None; this.lastrowid = Py.None; @@ -858,6 +861,15 @@ } return false; } + + /** + * Throw a ProgrammingError if the cursor has been closed. + */ + private void ensureOpen() { + if (closed) { + throw zxJDBC.makeException(zxJDBC.ProgrammingError, "cursor is closed"); + } + } } class CursorFunc extends PyBuiltinMethodSet { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |