You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ba...@apache.org on 2005/04/06 03:07:23 UTC
svn commit: r160247 - in incubator/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/execute/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/suites/
testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Author: bandaram
Date: Tue Apr 5 18:07:22 2005
New Revision: 160247
URL: http://svn.apache.org/viewcvs?view=rev&rev=160247
Log:
Derby-186: Set currentPosition for scrollable cursors when moving past the last row.
Submitted by Shreyas Kaushik. (Shreyas.Kaushik@Sun.COM)
Added:
incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out (with props)
incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java (with props)
Modified:
incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java?view=diff&r1=160246&r2=160247
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java Tue Apr 5 18:07:22 2005
@@ -750,6 +750,7 @@
else
{
afterLast = true;
+ currentPosition = positionInSource + 1;
}
}
Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out?view=auto&rev=160247
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out Tue Apr 5 18:07:22 2005
@@ -0,0 +1,9 @@
+Test testRelative starting
+Value=work1
+isFirst=false isLast=false isAfterLast=false
+Value=work3
+Value=work1
+isFirst=false isLast=false isAfterLast=true
+FAIL -- unexpected exception
+SQLSTATE(24000): SQL Exception: Invalid cursor state - no current row.
+SQL Exception: Invalid cursor state - no current row.
Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall?view=diff&r1=160246&r2=160247
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall Tue Apr 5 18:07:22 2005
@@ -14,4 +14,5 @@
jdbcapi/parameterMapping.java
jdbcapi/setTransactionIsolation.java
jdbcapi/prepStmtNull.java
+jdbcapi/testRelative.java
Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java?view=auto&rev=160247
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java Tue Apr 5 18:07:22 2005
@@ -0,0 +1,98 @@
+package org.apache.derbyTesting.functionTests.tests.jdbcapi;
+
+
+import java.sql.*;
+
+import org.apache.derby.tools.ij;
+import org.apache.derby.tools.JDBCDisplayUtil;
+
+public class testRelative {
+ public static void main(String[] args) {
+ test1(args);
+ }
+
+ public static void test1(String []args) {
+ Connection con;
+ ResultSet rs;
+ PreparedStatement stmt = null;
+ PreparedStatement pStmt = null;
+ Statement stmt1 = null;
+ String returnValue = null;
+
+ System.out.println("Test testRelative starting");
+
+ try
+ {
+ // use the ij utility to read the property file and
+ // make the initial connection.
+ ij.getPropertyArg(args);
+ con = ij.startJBMS();
+
+ con.setAutoCommit(false);
+
+ stmt = con.prepareStatement("create table testRelative(name varchar(10), i int)");
+ stmt.executeUpdate();
+ con.commit();
+
+ pStmt = con.prepareStatement("insert into testRelative values (?,?)");
+
+ pStmt.setString(1,"work1");
+ pStmt.setNull(2,1);
+ pStmt.addBatch();
+
+ pStmt.setString(1,"work2");
+ pStmt.setNull(2,2);
+ pStmt.addBatch();
+
+ pStmt.setString(1,"work3");
+ pStmt.setNull(2,3);
+ pStmt.addBatch();
+
+ pStmt.setString(1,"work4");
+ pStmt.setNull(2,4);
+ pStmt.addBatch();
+
+
+ pStmt.executeBatch();
+ con.commit();
+
+ stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
+ rs = stmt1.executeQuery("select * from testRelative");
+
+ rs.next(); // First Record
+ returnValue = rs.getString("name");
+ System.out.println("Value="+returnValue);
+
+ rs.relative(2);
+ System.out.println("isFirst=" + rs.isFirst() + " isLast=" + rs.isLast() + " isAfterLast=" + rs.isAfterLast());
+ returnValue = rs.getString("name");
+ System.out.println("Value="+returnValue);
+
+ rs.relative(-2);
+ returnValue = rs.getString("name");
+ System.out.println("Value="+returnValue);
+
+ rs.relative(10);
+ System.out.println("isFirst=" + rs.isFirst() + " isLast=" + rs.isLast() + " isAfterLast=" + rs.isAfterLast());
+
+ returnValue = rs.getString("name");
+ System.out.println("Value="+returnValue);
+
+ } catch(SQLException sqle) {
+ dumpSQLExceptions(sqle);
+ sqle.printStackTrace();
+ } catch(Throwable e) {
+ System.out.println("FAIL -- unexpected exception: "+e);
+ e.printStackTrace();
+
+ }
+ }
+
+ static private void dumpSQLExceptions (SQLException se) {
+ System.out.println("FAIL -- unexpected exception");
+ while (se != null) {
+ System.out.println("SQLSTATE("+se.getSQLState()+"): "+se);
+ se = se.getNextException();
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java
------------------------------------------------------------------------------
svn:eol-style = native