|
|
Sponsor |
Re: [jira] Commented: (DERBY-186) isFirst() returns true when relative(x) g: msg#00526apache.db.derby.devel
Please find the patch for this attached. I have added a test case for this as well. I ran the derbyall test suite without any failures. ~ Shreyas Shreyas Kaushik (JIRA) wrote: [ http://issues.apache.org/jira/browse/DERBY-186?page=comments#action_61704Index: java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java =================================================================== --- java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java (revision 159352) +++ java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java (working copy) @@ -750,6 +750,7 @@ else { afterLast = true; + currentPosition = positionInSource + 1; } } Index: java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java (revision 0) +++ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/testRelative.java (revision 0) @@ -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 Index: java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out (revision 0) +++ java/testing/org/apache/derbyTesting/functionTests/master/testRelative.out (revision 0) @@ -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.
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [jira] Commented: (DERBY-182) BUILDING.txt 3.4.6 refers to a readme file for testing that does not exist, Bernt M. Johnsen (JIRA) |
|---|---|
| Next by Date: | Re: [Patch] Re: About improvement of DERBY-134, TomohitoNakayama |
| Previous by Thread: | [jira] Commented: (DERBY-186) isFirst() returns true when relative(x) goes beyond result set, Shreyas Kaushik (JIRA) |
| Next by Thread: | Re: [jira] Commented: (DERBY-186) isFirst() returns true when relative(x) goes beyond result set, Mamta Satoor |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|