Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 25108 invoked from network); 22 Feb 2006 15:22:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Feb 2006 15:22:04 -0000 Received: (qmail 92187 invoked by uid 500); 22 Feb 2006 15:22:00 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 92151 invoked by uid 500); 22 Feb 2006 15:21:59 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 92142 invoked by uid 99); 22 Feb 2006 15:21:59 -0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Feb 2006 07:21:59 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 54575DD for ; Wed, 22 Feb 2006 16:21:38 +0100 (CET) Message-ID: <265995230.1140621698343.JavaMail.jira@ajax.apache.org> Date: Wed, 22 Feb 2006 16:21:38 +0100 (CET) From: "Andreas Korneliussen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Resolved: (DERBY-795) After calling ResultSet.relative(0) the cursor loses its position In-Reply-To: <1731914024.1136380380752.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-795?page=all ] Andreas Korneliussen resolved DERBY-795: ---------------------------------------- Resolution: Fixed > After calling ResultSet.relative(0) the cursor loses its position > ----------------------------------------------------------------- > > Key: DERBY-795 > URL: http://issues.apache.org/jira/browse/DERBY-795 > Project: Derby > Type: Bug > Components: JDBC > Versions: 10.1.2.1 > Environment: Any > Reporter: Andreas Korneliussen > Assignee: Andreas Korneliussen > Priority: Minor > Attachments: DERBY-795.diff, DERBY-795.stat > > After calling rs.relative(0), on a scrollable ResultSet, the cursor looses its position, and a rs.getXXX(..) fails with: > SQL Exception: Invalid cursor state - no current row. > Probably caused by the following logic in ScrollInsensitiveResultSet.getRelativeRow(int row): > // Return the current row for 0 > if (row == 0) > { > if ((beforeFirst || afterLast) || > (!beforeFirst && !afterLast)) { > return null; > } else { > return getRowFromHashTable(currentPosition); > } > } > The if () will always evaluate to true, regardless of the values of beforeFirst and afterLast > Test code: > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.ResultSet; > import java.sql.SQLException; > import java.sql.Statement; > public class RelativeZeroIssue { > > public static void main(String[] args) throws Exception { > > Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); > Connection con = DriverManager.getConnection("jdbc:derby:testdb2;create=true"); > con.setAutoCommit(false); > try { > Statement statement = con.createStatement(); > > /** Create the table */ > statement.execute("create table t1(id int)"); > statement.execute("insert into t1 values 1,2,3,4,5,6,7,8"); > > Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, > ResultSet.CONCUR_READ_ONLY); > ResultSet rs = s.executeQuery("select * from t1"); > rs.next(); > System.out.println(rs.getInt(1)); > System.out.println(rs.relative(0)); > System.out.println(rs.getInt(1)); > } finally { > > con.rollback(); > con.close(); > } > } > > } > Output from test: > 1 > false > Exception in thread "main" SQL Exception: Invalid cursor state - no current row. > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedResultSet.checkOnRow(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedResultSet.getColumn(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedResultSet.getInt(Unknown Source) > at derbytest.RelativeZeroIssue.main(RelativeZeroIssue.java:51) > Java Result: 1 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira